summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-09-02 10:50:14 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-09-02 10:52:55 +0200
commit2e9e706a8271bbb42ad696c3383912facdd7d45f (patch)
tree3abd9d7445f6263693ff2f4adc068fd9aa1dc4ae
parenta07c1f56aac1c0f6c8334760009b678cbf9d6138 (diff)
downloadphp-git-2e9e706a8271bbb42ad696c3383912facdd7d45f.tar.gz
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 ad750c3bb6e7b48384c6265eb9d3bcf5b4000652, 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.
-rw-r--r--Zend/tests/generators/yield_from_valid_exception.phpt3
-rw-r--r--Zend/zend_generators.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/Zend/tests/generators/yield_from_valid_exception.phpt b/Zend/tests/generators/yield_from_valid_exception.phpt
index 3af35f53af..d3e054bfaf 100644
--- a/Zend/tests/generators/yield_from_valid_exception.phpt
+++ b/Zend/tests/generators/yield_from_valid_exception.phpt
@@ -15,7 +15,8 @@ class FooBar implements Iterator {
function gen() {
try {
- yield from new FooBar;
+ // the fact that the yield from result is used is relevant.
+ var_dump(yield from new FooBar);
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index bb3260b11b..0ed92f4ca2 100644
--- a/Zend/zend_generators.c
+++ b/Zend/zend_generators.c
@@ -740,7 +740,7 @@ static int zend_generator_get_next_delegated_value(zend_generator *generator) /*
return SUCCESS;
exception:
- zend_rethrow_exception(generator->execute_data);
+ zend_generator_throw_exception(generator, NULL);
failure:
zval_ptr_dtor(&generator->values);