File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #68775: yield in a function argument crashes or loops indefinitely
3
+ --FILE--
4
+ <?php
5
+
6
+ function a ($ x ) {
7
+ var_dump ($ x );
8
+ }
9
+
10
+ function gen () {
11
+ a (yield );
12
+ }
13
+
14
+ $ g = gen ();
15
+ $ g ->send (1 );
16
+
17
+ ?>
18
+ --EXPECT--
19
+ int(1)
Original file line number Diff line number Diff line change @@ -303,8 +303,8 @@ ZEND_API void zend_generator_resume(zend_generator *generator) /* {{{ */
303
303
zend_execute_data * original_execute_data = EG (current_execute_data );
304
304
zend_class_entry * original_scope = EG (scope );
305
305
zend_vm_stack original_stack = EG (vm_stack );
306
-
307
306
original_stack -> top = EG (vm_stack_top );
307
+
308
308
/* Set executor globals */
309
309
EG (current_execute_data ) = generator -> execute_data ;
310
310
EG (scope ) = generator -> execute_data -> func -> common .scope ;
@@ -314,8 +314,7 @@ ZEND_API void zend_generator_resume(zend_generator *generator) /* {{{ */
314
314
315
315
/* We want the backtrace to look as if the generator function was
316
316
* called from whatever method we are current running (e.g. next()).
317
- * So we have to link generator call frame with caller call frames */
318
-
317
+ * So we have to link generator call frame with caller call frame. */
319
318
generator -> execute_data -> prev_execute_data = original_execute_data ;
320
319
321
320
/* Resume execution */
@@ -329,6 +328,7 @@ ZEND_API void zend_generator_resume(zend_generator *generator) /* {{{ */
329
328
}
330
329
331
330
/* Restore executor globals */
331
+ generator -> stack -> top = EG (vm_stack_top );
332
332
EG (current_execute_data ) = original_execute_data ;
333
333
EG (scope ) = original_scope ;
334
334
EG (vm_stack_top ) = original_stack -> top ;
You can’t perform that action at this time.
0 commit comments