Skip to content

Commit ccb5591

Browse files
committed
Merge branch 'PHP-7.1'
2 parents 23ea38d + 649494c commit ccb5591

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

Zend/tests/generators/bug74606.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Bug #74606 (Segfault within try/catch/finally nesting in Generators)
3+
--FILE--
4+
<?php
5+
6+
function gen() {
7+
$array = ["foo"];
8+
$array[] = "bar";
9+
10+
foreach ($array as $item) {
11+
try {
12+
try {
13+
yield;
14+
} finally {
15+
echo "fin $item\n";
16+
}
17+
} catch (\Exception $e) {
18+
echo "catch\n";
19+
continue;
20+
}
21+
}
22+
}
23+
gen()->throw(new Exception);
24+
25+
?>
26+
--EXPECT--
27+
fin foo
28+
catch
29+
fin bar

Zend/zend_generators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static void zend_generator_cleanup_unfinished_execution(
108108
if (UNEXPECTED(generator->frozen_call_stack)) {
109109
zend_generator_restore_call_stack(generator);
110110
}
111-
zend_cleanup_unfinished_execution(execute_data, op_num, 0);
111+
zend_cleanup_unfinished_execution(execute_data, op_num, catch_op_num);
112112
}
113113
}
114114
/* }}} */

0 commit comments

Comments
 (0)