From: Dmitry Stogov Date: Mon, 23 Dec 2013 12:04:10 +0000 (+0400) Subject: Fixed bug #66334 (Memory Leak in new pass1_5.c optimizations). (Terry) X-Git-Tag: php-5.6.0alpha1~98 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ccb29a6e41afc3a5ced31e86951fca5119a2e8d0;p=php Fixed bug #66334 (Memory Leak in new pass1_5.c optimizations). (Terry) --- diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c index 4601562566..5ab5bf400b 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_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 index 0000000000..b2c6d7b92c --- /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-- + +--FILE-- +