Commit:    c699696c438eeb3214d3a645110d03f98f8e979e
Author:    Dmitry Stogov <dmi...@zend.com>         Mon, 23 Dec 2013 16:04:10 
+0400
Committer: Anatol Belski <a...@php.net>      Mon, 23 Dec 2013 20:30:27 +0100
Parents:   8d64f0ee711b00c0fdda37e8e55615b0d2510269
Branches:  str_size_and_int64

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=c699696c438eeb3214d3a645110d03f98f8e979e

Log:
Fixed bug #66334 (Memory Leak in new pass1_5.c optimizations). (Terry)

Bugs:
https://bugs.php.net/66334

Changed paths:
  M  ext/opcache/Optimizer/pass1_5.c
  A  ext/opcache/tests/bug66334.phpt


Diff:
diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c
index 9de8590..68db08a 100644
--- a/ext/opcache/Optimizer/pass1_5.c
+++ b/ext/opcache/Optimizer/pass1_5.c
@@ -383,9 +383,11 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
                                        zend_module_entry *m;
                                        char *lc_name = zend_str_tolower_dup(
                                                        
Z_STRVAL(ZEND_OP1_LITERAL(opline - 1)), Z_STRSIZE(ZEND_OP1_LITERAL(opline - 
1)));
+                                       int found = 
zend_hash_find(&module_registry,
+                                                       lc_name, 
Z_STRSIZE(ZEND_OP1_LITERAL(opline - 1)) + 1, (void *)&m) == SUCCESS;
 
-                                       if (zend_hash_find(&module_registry,
-                                                       lc_name, 
Z_STRSIZE(ZEND_OP1_LITERAL(opline - 1)) + 1, (void *)&m) == FAILURE) {
+                                       efree(lc_name);
+                                       if (!found) {
                                                if (!PG(enable_dl)) {
                                                        break;
                                                } else {
@@ -405,7 +407,6 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
                                                
literal_dtor(&ZEND_OP1_LITERAL(opline));
                                                MAKE_NOP(opline);
                                        }
-                                       efree(lc_name);
                                } else if (Z_STRSIZE(ZEND_OP1_LITERAL(opline)) 
== sizeof("defined")-1 &&
                                        
!memcmp(Z_STRVAL(ZEND_OP1_LITERAL(opline)),
                                                "defined", 
sizeof("defined")-1)) {
diff --git a/ext/opcache/tests/bug66334.phpt b/ext/opcache/tests/bug66334.phpt
new file mode 100644
index 0000000..b2c6d7b
--- /dev/null
+++ b/ext/opcache/tests/bug66334.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #66334 (Memory Leak in new pass1_5.c optimizations)
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.file_update_protection=0
+enable_dl=0
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+if (extension_loaded("unknown_extension")) {
+       var_dump(1);
+} else {
+       var_dump(2);
+}
+--EXPECT--
+int(2)


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to