Skip to content

Commit e112b84

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
2 parents 8c73fc8 + 420d11e commit e112b84

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ PHP NEWS
1010
. Fixed bug #75786 (segfault when using spread operator on generator passed
1111
by reference). (Nikita)
1212
. Fixed bug #75799 (arg of get_defined_functions is optional). (carusogabriel)
13+
. Fixed bug #75396 (Exit inside generator finally results in fatal error).
14+
(Nikita)
1315

1416
- Opcache:
1517
. Fixed bug #75687 (var 8 (TMP) has array key type but not value type).

Zend/tests/generators/bug75396.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #75396: Exit inside generator finally results in fatal error
3+
--FILE--
4+
<?php
5+
6+
$gen = (function () {
7+
yield 42;
8+
9+
try {
10+
echo "Try\n";
11+
exit("Exit\n");
12+
} finally {
13+
echo "Finally\n";
14+
}
15+
})();
16+
17+
$gen->send("x");
18+
19+
?>
20+
--EXPECT--
21+
Try
22+
Exit

Zend/zend_generators.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ static void zend_generator_dtor_storage(zend_object *object) /* {{{ */
185185
generator->node.parent = NULL;
186186
}
187187

188-
if (EXPECTED(!ex) || EXPECTED(!(ex->func->op_array.fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK))) {
188+
if (EXPECTED(!ex) || EXPECTED(!(ex->func->op_array.fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK))
189+
|| CG(unclean_shutdown)) {
189190
return;
190191
}
191192

0 commit comments

Comments
 (0)