diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2020-06-08 11:32:24 +0200 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-06-08 11:32:24 +0200 |
| commit | 57f408e87ce4c3a424459aae17c0ff440f507bfe (patch) | |
| tree | c5409b1dea82592db0135a3a756d39c2069a6d99 | |
| parent | 13909e5555cd941be3062470b47996b7496e90da (diff) | |
| parent | df2db7fceaff4f46909f1aa8b31f0a9010631fc9 (diff) | |
| download | php-git-57f408e87ce4c3a424459aae17c0ff440f507bfe.tar.gz | |
Merge branch 'PHP-7.4'
* PHP-7.4:
Fixed bug #79657
| -rw-r--r-- | Zend/tests/bug79657.phpt | 42 | ||||
| -rw-r--r-- | Zend/zend_generators.c | 1 |
2 files changed, 43 insertions, 0 deletions
diff --git a/Zend/tests/bug79657.phpt b/Zend/tests/bug79657.phpt new file mode 100644 index 0000000000..fb2ccab3e3 --- /dev/null +++ b/Zend/tests/bug79657.phpt @@ -0,0 +1,42 @@ +--TEST-- +Bug #79657: "yield from" hangs when invalid value encountered +--FILE-- +<?php + +function throwException(): iterable +{ + throw new Exception(); +} + +function loop(): iterable +{ + $callbacks = [ + function () { + yield 'first'; + }, + function () { + yield from throwException(); + } + ]; + + foreach ($callbacks as $callback) { + yield from $callback(); + } +} + +function get(string $first, int $second): array +{ + return []; +} + +get(...loop()); + +?> +--EXPECTF-- +Fatal error: Uncaught Exception in %s:%d +Stack trace: +#0 %s(%d): throwException() +#1 %s(%d): {closure}() +#2 %s(%d): loop() +#3 {main} + thrown in %s on line %d diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index b4ffb04414..a74ae530b1 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -794,6 +794,7 @@ try_again: } else { generator = zend_generator_get_current(orig_generator); zend_generator_throw_exception(generator, NULL); + orig_generator->flags &= ~ZEND_GENERATOR_DO_INIT; goto try_again; } } |
