summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNuno Lopes <nlopess@php.net>2012-01-01 22:45:58 +0000
committerNuno Lopes <nlopess@php.net>2012-01-01 22:45:58 +0000
commitbac57c94fb90b609b819ac87314a12ce605bcef4 (patch)
tree62aeac35fc01c9bf85844b0bd60a9dda6d444eda
parente4ca0ed09f035b362f48f30b8a2c0fcf47764801 (diff)
downloadphp-git-bac57c94fb90b609b819ac87314a12ce605bcef4.tar.gz
fix memory leak in compile_string when there's a parse error (used e.g. in eval or assert)
-rw-r--r--Zend/zend_language_scanner.l2
-rw-r--r--tests/lang/019.phpt8
2 files changed, 7 insertions, 3 deletions
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index da2abd3159..fd9ab9b65d 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -536,6 +536,8 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
if (compiler_result==1) {
CG(active_op_array) = original_active_op_array;
CG(unclean_shutdown)=1;
+ destroy_op_array(op_array TSRMLS_CC);
+ efree(op_array);
retval = NULL;
} else {
zend_do_return(NULL, 0 TSRMLS_CC);
diff --git a/tests/lang/019.phpt b/tests/lang/019.phpt
index 6c0a1cab62..be65fb0db8 100644
--- a/tests/lang/019.phpt
+++ b/tests/lang/019.phpt
@@ -3,8 +3,6 @@ eval() test
--FILE--
<?php
-error_reporting(0);
-
eval("function test() { echo \"hey, this is a function inside an eval()!\\n\"; }");
$i=0;
@@ -13,7 +11,9 @@ while ($i<10) {
test();
$i++;
}
---EXPECT--
+
+eval('-');
+--EXPECTF--
hey, this is a regular echo'd eval()
hey, this is a function inside an eval()!
hey, this is a regular echo'd eval()
@@ -34,3 +34,5 @@ hey, this is a regular echo'd eval()
hey, this is a function inside an eval()!
hey, this is a regular echo'd eval()
hey, this is a function inside an eval()!
+
+Parse error: syntax error, unexpected end of file in %s019.php(12) : eval()'d code on line 1