com php-src: Fix ClosedGeneratorException possibly thrown into wrong scope: NEWS Zend/tests/generators/mutli_yield_from_with_except ion.phpt
Zend/zend_generators.c

From: Date: Sat, 23 Jul 2016 14:39:21 +0000
Subject: com php-src: Fix ClosedGeneratorException possibly thrown into wrong scope: NEWS Zend/tests/generators/mutli_yield_from_with_except ion.phpt
Zend/zend_generators.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-93340@lists.php.net to get a copy of this message
Commit: 6046acf93e4f9de43efb12d53dd58738959fb20e Author: Bob Weinand <bobwei9@hotmail.com> Sat, 23 Jul 2016 16:39:21 +0200 Parents: f12fd5c2d323ad4f76bea50fc2adecc3db0cae59 Branches: PHP-7.0 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6046acf93e4f9de43efb12d53dd58738959fb20e Log: Fix ClosedGeneratorException possibly thrown into wrong scope Changed paths: M NEWS M Zend/tests/generators/mutli_yield_from_with_exception.phpt M Zend/zend_generators.c Diff: diff --git a/NEWS b/NEWS index bc7b3d9..3909a2c 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,8 @@ PHP NEWS . Fixed bug #72024 (microtime() leaks memory). (maroszek at gmx dot net) . Fixed bug #71911 (Unable to set --enable-debug on building extensions by phpize on Windows). (Yuji Uchiyama) + . Fixed bug causing ClosedGeneratorException being thrown into the calling + code instead of the Generator yielding from. (Bob) - COM: . Fixed bug #72569 (DOTNET/COM array parameters broke in PHP7). (Anatol) diff --git a/Zend/tests/generators/mutli_yield_from_with_exception.phpt b/Zend/tests/generators/mutli_yield_from_with_exception.phpt index 2dc7181..4be2449 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 89b919a..f1cc09e 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);

« previous php.cvs (#93340) next »