File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -270,20 +270,21 @@ ZEND_API zend_fiber_context *zend_fiber_switch_context(zend_fiber_context *to)
270
270
271
271
EG (current_fiber ) = from ;
272
272
273
- zend_fiber_restore_vm_state (& state );
274
-
275
273
zend_fiber_context * previous = transfer .data ;
276
274
previous -> handle = transfer .context ;
277
275
278
- if (UNEXPECTED (previous -> flags & ZEND_FIBER_FLAG_BAILOUT )) {
279
- // zend_bailout() was called in the fiber, so call it again in the previous fiber or {main}.
280
- zend_bailout ();
281
- }
276
+ zend_fiber_restore_vm_state (& state );
282
277
278
+ /* Destroy context first to ensure it does not leak if some extension does custom bailout handling. */
283
279
if (previous -> status == ZEND_FIBER_STATUS_DEAD ) {
284
280
zend_fiber_destroy_context (previous );
285
281
}
286
282
283
+ /* Propagate bailout to current fiber / main. */
284
+ if (UNEXPECTED (previous -> flags & ZEND_FIBER_FLAG_BAILOUT )) {
285
+ zend_bailout ();
286
+ }
287
+
287
288
return previous ;
288
289
}
289
290
@@ -493,7 +494,7 @@ ZEND_METHOD(Fiber, suspend)
493
494
fiber -> execute_data = EG (current_execute_data );
494
495
fiber -> stack_bottom -> prev_execute_data = NULL ;
495
496
496
- zend_fiber_switch_context (zend_fiber_get_context ( fiber ) -> caller );
497
+ zend_fiber_switch_context (fiber -> caller );
497
498
498
499
if (fiber -> flags & ZEND_FIBER_FLAG_DESTROYED ) {
499
500
// This occurs when the fiber is GC'ed while suspended.
You can’t perform that action at this time.
0 commit comments