com php-src: Fixed bug #74606 (Segfault within try/catch/finally nesting in Generators): NEWS Zend/tests/generators/bug74606.phpt
Zend/zend_generators.c
| From: | Bob Weinand | Date: | Wed, 17 May 2017 17:58:51 +0000 |
| Subject: | com php-src: Fixed bug #74606 (Segfault within try/catch/finally nesting in Generators): NEWS Zend/tests/generators/bug74606.phpt Zend/zend_generators.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-97845@lists.php.net to get a copy of this message | ||
Commit: 649494c0ee54102ac4a6c62fd5faf38143efb107
Author: Bob Weinand <bobwei9@hotmail.com> Wed, 17 May 2017 19:56:49 +0200
Parents: 78b10dd9d6994c9ef0bef01100daab81b233460d
Branches: PHP-7.1
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=649494c0ee54102ac4a6c62fd5faf38143efb107
Log:
Fixed bug #74606 (Segfault within try/catch/finally nesting in Generators)
Thanks to Nikita for pointing out the error source.
Bugs:
https://bugs.php.net/74606
Changed paths:
M NEWS
A Zend/tests/generators/bug74606.phpt
M Zend/zend_generators.c
Diff:
diff --git a/NEWS b/NEWS
index fcc0f40..e5cafc9 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ PHP NEWS
. Fixed bug #74546 (SIGILL in ZEND_FETCH_CLASS_CONSTANT_SPEC_CONST_CONST).
(Laruence)
. Fixed bug #74589 (__DIR__ wrong for unicode character). (Anatol)
+ . Fixed bug #74606 (Segfault within try/catch/finally nesting in Generators).
+ (Bob, Nikita)
- intl:
. Fixed bug #74468 (wrong reflection on Collator::sortWithSortKeys). (villfa)
diff --git a/Zend/tests/generators/bug74606.phpt b/Zend/tests/generators/bug74606.phpt
new file mode 100644
index 0000000..cfb7f7f
--- /dev/null
+++ b/Zend/tests/generators/bug74606.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #74606 (Segfault within try/catch/finally nesting in Generators)
+--FILE--
+<?php
+
+function gen() {
+ $array = ["foo"];
+ $array[] = "bar";
+
+ foreach ($array as $item) {
+ try {
+ try {
+ yield;
+ } finally {
+ echo "fin $item\n";
+ }
+ } catch (\Exception $e) {
+ echo "catch\n";
+ continue;
+ }
+ }
+}
+gen()->throw(new Exception);
+
+?>
+--EXPECT--
+fin foo
+catch
+fin bar
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index 945c361..99145ad 100644
--- a/Zend/zend_generators.c
+++ b/Zend/zend_generators.c
@@ -108,7 +108,7 @@ static void zend_generator_cleanup_unfinished_execution(
if (UNEXPECTED(generator->frozen_call_stack)) {
zend_generator_restore_call_stack(generator);
}
- zend_cleanup_unfinished_execution(execute_data, op_num, 0);
+ zend_cleanup_unfinished_execution(execute_data, op_num, catch_op_num);
}
}
/* }}} */