com php-src: Fixed bug #66334 (Memory Leak in new pass1_5 .c optimizations). (Terry): ext/opcache/Optim izer/pass1_5.c ext/opcache/tests/bug66334
.phpt
| From: | Dmitry Stogov | Date: | Mon, 23 Dec 2013 12:04:10 +0000 |
| Subject: | com php-src: Fixed bug #66334 (Memory Leak in new pass1_5 .c optimizations). (Terry): ext/opcache/Optim izer/pass1_5.c ext/opcache/tests/bug66334 .phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75422@lists.php.net to get a copy of this message | ||
Commit: ccb29a6e41afc3a5ced31e86951fca5119a2e8d0
Author: Dmitry Stogov <dmitry@zend.com> Mon, 23 Dec 2013 16:04:10 +0400
Parents: 8650d2dda65cf7ac70bf83323ca8036d01dbe349
Branches: PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ccb29a6e41afc3a5ced31e86951fca5119a2e8d0
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 4601562..5ab5bf4 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 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)