summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2016-07-23 16:39:21 +0200
committerBob Weinand <bobwei9@hotmail.com>2016-07-23 16:39:21 +0200
commit6046acf93e4f9de43efb12d53dd58738959fb20e (patch)
tree3fc145581915440025babbe76e6221ad92a4b545 /Zend
parentf12fd5c2d323ad4f76bea50fc2adecc3db0cae59 (diff)
downloadphp-git-6046acf93e4f9de43efb12d53dd58738959fb20e.tar.gz
Fix ClosedGeneratorException possibly thrown into wrong scope
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/generators/mutli_yield_from_with_exception.phpt7
-rw-r--r--Zend/zend_generators.c10
2 files changed, 13 insertions, 4 deletions
diff --git a/Zend/tests/generators/mutli_yield_from_with_exception.phpt b/Zend/tests/generators/mutli_yield_from_with_exception.phpt
index 2dc71815f0..4be2449a46 100644
--- a/Zend/tests/generators/mutli_yield_from_with_exception.phpt
+++ b/Zend/tests/generators/mutli_yield_from_with_exception.phpt
@@ -40,11 +40,10 @@ Stack trace:
#2 %s(%d): Generator->next()
#3 {main}
Generator 1
-
-Fatal error: Uncaught ClosedGeneratorException: Generator yielded from aborted, no return value available in %s:%d
+Caught exception!
+ClosedGeneratorException: Generator yielded from aborted, no return value available in %s:%d
Stack trace:
#0 [internal function]: gen(Object(Generator))
#1 %s(%d): Generator->current()
#2 {main}
- thrown in %s on line %d
-
+NULL
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index 89b919a48c..f1cc09e938 100644
--- a/Zend/zend_generators.c
+++ b/Zend/zend_generators.c
@@ -521,6 +521,16 @@ ZEND_API zend_generator *zend_generator_update_current(zend_generator *generator
zend_throw_exception(zend_ce_ClosedGeneratorException, "Generator yielded from aborted, no return value available", 0);
EG(current_execute_data) = original_execute_data;
+
+ if (!((old_root ? old_root : generator)->flags & ZEND_GENERATOR_CURRENTLY_RUNNING)) {
+ leaf->node.ptr.root = root;
+ root->node.parent = NULL;
+ if (old_root) {
+ OBJ_RELEASE(&old_root->std);
+ }
+ zend_generator_resume(leaf);
+ return leaf->node.ptr.root; /* this may be updated during zend_generator_resume! */
+ }
} else {
zval_ptr_dtor(&root->value);
ZVAL_COPY(&root->value, &root->node.parent->value);