]> granicus.if.org Git - php/commitdiff
Fix bug #67497: eval with parse error causes segfault in generator
authorNikita Popov <nikic@php.net>
Wed, 2 Jul 2014 15:33:31 +0000 (17:33 +0200)
committerNikita Popov <nikic@php.net>
Wed, 2 Jul 2014 15:33:31 +0000 (17:33 +0200)
NEWS
Zend/tests/generators/bug67497.phpt [new file with mode: 0644]
Zend/zend_generators.c

diff --git a/NEWS b/NEWS
index 4a848548aba136213e79399f7b1bbf34c4ea1c82..9bfa384e8252f7cf3630567f794a42e933a654e2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ PHP                                                                        NEWS
     match). (Bob)
   . Fixed bug #67091 (make install fails to install libphp5.so on FreeBSD 10.0).
     (Ferenc)
+  . Fixed buf #67497 (eval with parse error causes segmentation fault in
+    generator). (Nikita)
 
 - CLI server:
   . Implemented FR #67429 (CLI server is missing some new HTTP response codes).
diff --git a/Zend/tests/generators/bug67497.phpt b/Zend/tests/generators/bug67497.phpt
new file mode 100644 (file)
index 0000000..483857b
--- /dev/null
@@ -0,0 +1,19 @@
+--TEST--
+Bug #67467: eval with parse error causes segmentation fault in generator
+--FILE--
+<?php
+
+function gen() {
+    $a = 1;
+    yield $a;
+}
+
+@eval('abc');
+
+$values = gen();
+$values->next();
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
index a5313dc1a31bf31659aa2f51d120d1e13f8d759a..b9722b45a0c0cd22763b1b0e5cf64c13a96fcbef 100644 (file)
@@ -125,6 +125,7 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
                /* A fatal error / die occurred during the generator execution. Trying to clean
                 * up the stack may not be safe in this case. */
                if (CG(unclean_shutdown)) {
+                       generator->execute_data = NULL;
                        return;
                }