diff options
author | Nikita Popov <nikic@php.net> | 2013-11-30 13:05:40 +0100 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2013-11-30 13:08:31 +0100 |
commit | 9589cae8cb1b13710ca36491f30b569113f9e329 (patch) | |
tree | 03f9101317e0bbac4c7f5f0fa76ad2b83c064db4 /Zend/zend_generators.c | |
parent | 5f09944662e09ea0b3f93cfab8702f188955e68c (diff) | |
download | php-git-9589cae8cb1b13710ca36491f30b569113f9e329.tar.gz |
Fixed bug #66041: list() fails to unpack yielded ArrayAccess object
Yield return values now use IS_VAR rather than IS_TMP_VAR. This
fixes the issue with list() and should also be faster as it avoids
doing a zval copy.
Diffstat (limited to 'Zend/zend_generators.c')
-rw-r--r-- | Zend/zend_generators.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 0af20f4593..c0116332e7 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -55,6 +55,11 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished zval_ptr_dtor(&execute_data->current_this); } + if (!finished_execution && generator->send_target) { + Z_DELREF_PP(generator->send_target); + generator->send_target = NULL; + } + /* A fatal error / die occurred during the generator execution. Trying to clean * up the stack may not be safe in this case. */ if (CG(unclean_shutdown)) { @@ -519,8 +524,12 @@ ZEND_METHOD(Generator, send) return; } - /* Put sent value into the TMP_VAR slot */ - MAKE_COPY_ZVAL(&value, &generator->send_target->tmp_var); + /* Put sent value in the target VAR slot, if it is used */ + if (generator->send_target) { + Z_DELREF_PP(generator->send_target); + Z_ADDREF_P(value); + *generator->send_target = value; + } zend_generator_resume(generator TSRMLS_CC); |