summaryrefslogtreecommitdiff
path: root/Zend/zend_generators.c
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2013-11-30 13:05:40 +0100
committerNikita Popov <nikic@php.net>2013-11-30 13:08:31 +0100
commit9589cae8cb1b13710ca36491f30b569113f9e329 (patch)
tree03f9101317e0bbac4c7f5f0fa76ad2b83c064db4 /Zend/zend_generators.c
parent5f09944662e09ea0b3f93cfab8702f188955e68c (diff)
downloadphp-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.c13
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);