]> granicus.if.org Git - php/commitdiff
fix memory leak in compile_string when there's a parse error (used e.g. in eval or...
authorNuno Lopes <nlopess@php.net>
Sun, 1 Jan 2012 22:45:58 +0000 (22:45 +0000)
committerNuno Lopes <nlopess@php.net>
Sun, 1 Jan 2012 22:45:58 +0000 (22:45 +0000)
Zend/zend_language_scanner.l
tests/lang/019.phpt

index 629168f813847d2130740cd8295432748ef2038d..7668798297e5d9a714feb8db2b5e5826afac5e34 100644 (file)
@@ -756,6 +756,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);
index 6c0a1cab6240367bac8d4e2381cb156a192502bc..be65fb0db83e2e09e5ec59a40c96d51b79630625 100644 (file)
@@ -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