Skip to content

Commit 2e9e706

Browse files
committed
Fix throwing of yield from related exceptions into generator
Use the general zend_generator_throw_exception() helper for this. Otherwise we don't handle the off-by-one opline correctly (should we maybe just stop doing that?) This is a followup to ad750c3, which fixed a different yield from exception handling problem that happened to show up in the same test case from oss-fuzz #25321. Now both issues should be fixed.
1 parent a07c1f5 commit 2e9e706

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Zend/tests/generators/yield_from_valid_exception.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class FooBar implements Iterator {
1515

1616
function gen() {
1717
try {
18-
yield from new FooBar;
18+
// the fact that the yield from result is used is relevant.
19+
var_dump(yield from new FooBar);
1920
} catch (Exception $e) {
2021
echo $e->getMessage(), "\n";
2122
}

Zend/zend_generators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ static int zend_generator_get_next_delegated_value(zend_generator *generator) /*
740740
return SUCCESS;
741741

742742
exception:
743-
zend_rethrow_exception(generator->execute_data);
743+
zend_generator_throw_exception(generator, NULL);
744744

745745
failure:
746746
zval_ptr_dtor(&generator->values);

0 commit comments

Comments
 (0)