]> granicus.if.org Git - php/commitdiff
Fixed bug #66334 (Memory Leak in new pass1_5.c optimizations). (Terry)
authorDmitry Stogov <dmitry@zend.com>
Mon, 23 Dec 2013 12:04:10 +0000 (16:04 +0400)
committerDmitry Stogov <dmitry@zend.com>
Mon, 23 Dec 2013 12:04:10 +0000 (16:04 +0400)
ext/opcache/Optimizer/pass1_5.c
ext/opcache/tests/bug66334.phpt [new file with mode: 0644]

index 46015625668199d618cc30a08c97832badb5a84b..5ab5bf400bd98d3fa7ce02f1bbc2c2f1b6fcc8c0 100644 (file)
@@ -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_STRLEN(ZEND_OP1_LITERAL(opline - 1)));
+                                       int found = zend_hash_find(&module_registry,
+                                                       lc_name, Z_STRLEN(ZEND_OP1_LITERAL(opline - 1)) + 1, (void *)&m) == SUCCESS;
 
-                                       if (zend_hash_find(&module_registry,
-                                                       lc_name, Z_STRLEN(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_STRLEN(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 (file)
index 0000000..b2c6d7b
--- /dev/null
@@ -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)