Skip to content

Commit

Permalink
fix memory leak in compile_string when there's a parse error (used e.…
Browse files Browse the repository at this point in the history
…g. in eval or assert)
  • Loading branch information
nunoplopes committed Jan 1, 2012
1 parent e4ca0ed commit bac57c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Zend/zend_language_scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions tests/lang/019.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
Expand All @@ -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

0 comments on commit bac57c9

Please sign in to comment.