diff options
author | Nikita Popov <nikic@php.net> | 2015-01-09 17:58:41 +0100 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2015-01-09 17:59:41 +0100 |
commit | 41a249fef602b8cbfdc70fc8179e48cc1387b821 (patch) | |
tree | 3ef14ccd348f8c09ea68cad2038e6d53372d9d3b /Zend | |
parent | 32f761d7f856d13ca17814899f7317614a6c4d9d (diff) | |
download | php-git-41a249fef602b8cbfdc70fc8179e48cc1387b821.tar.gz |
Fix bug #68775
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/tests/bug68775.phpt | 19 | ||||
-rw-r--r-- | Zend/zend_generators.c | 6 |
2 files changed, 22 insertions, 3 deletions
diff --git a/Zend/tests/bug68775.phpt b/Zend/tests/bug68775.phpt new file mode 100644 index 0000000000..ce0eaedf53 --- /dev/null +++ b/Zend/tests/bug68775.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #68775: yield in a function argument crashes or loops indefinitely +--FILE-- +<?php + +function a($x) { + var_dump($x); +} + +function gen() { + a(yield); +} + +$g = gen(); +$g->send(1); + +?> +--EXPECT-- +int(1) diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 17bd4a3da5..ae46555340 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -303,8 +303,8 @@ ZEND_API void zend_generator_resume(zend_generator *generator) /* {{{ */ zend_execute_data *original_execute_data = EG(current_execute_data); zend_class_entry *original_scope = EG(scope); zend_vm_stack original_stack = EG(vm_stack); - original_stack->top = EG(vm_stack_top); + /* Set executor globals */ EG(current_execute_data) = generator->execute_data; EG(scope) = generator->execute_data->func->common.scope; @@ -314,8 +314,7 @@ ZEND_API void zend_generator_resume(zend_generator *generator) /* {{{ */ /* We want the backtrace to look as if the generator function was * called from whatever method we are current running (e.g. next()). - * So we have to link generator call frame with caller call frames */ - + * So we have to link generator call frame with caller call frame. */ generator->execute_data->prev_execute_data = original_execute_data; /* Resume execution */ @@ -329,6 +328,7 @@ ZEND_API void zend_generator_resume(zend_generator *generator) /* {{{ */ } /* Restore executor globals */ + generator->stack->top = EG(vm_stack_top); EG(current_execute_data) = original_execute_data; EG(scope) = original_scope; EG(vm_stack_top) = original_stack->top; |