Skip to content

Commit 57f408e

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #79657
2 parents 13909e5 + df2db7f commit 57f408e

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

Zend/tests/bug79657.phpt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
Bug #79657: "yield from" hangs when invalid value encountered
3+
--FILE--
4+
<?php
5+
6+
function throwException(): iterable
7+
{
8+
throw new Exception();
9+
}
10+
11+
function loop(): iterable
12+
{
13+
$callbacks = [
14+
function () {
15+
yield 'first';
16+
},
17+
function () {
18+
yield from throwException();
19+
}
20+
];
21+
22+
foreach ($callbacks as $callback) {
23+
yield from $callback();
24+
}
25+
}
26+
27+
function get(string $first, int $second): array
28+
{
29+
return [];
30+
}
31+
32+
get(...loop());
33+
34+
?>
35+
--EXPECTF--
36+
Fatal error: Uncaught Exception in %s:%d
37+
Stack trace:
38+
#0 %s(%d): throwException()
39+
#1 %s(%d): {closure}()
40+
#2 %s(%d): loop()
41+
#3 {main}
42+
thrown in %s on line %d

Zend/zend_generators.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ ZEND_API void zend_generator_resume(zend_generator *orig_generator) /* {{{ */
794794
} else {
795795
generator = zend_generator_get_current(orig_generator);
796796
zend_generator_throw_exception(generator, NULL);
797+
orig_generator->flags &= ~ZEND_GENERATOR_DO_INIT;
797798
goto try_again;
798799
}
799800
}

0 commit comments

Comments
 (0)