Skip to content

Commit f4d5d11

Browse files
committed
* fix fiber memory leak for fci
1 parent 650bf37 commit f4d5d11

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

Zend/zend_fibers.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,19 +1270,19 @@ static void zend_fiber_object_destroy(zend_object *object)
12701270
fiber->coroutine = NULL;
12711271
coroutine->extended_data = NULL;
12721272

1273-
/*
1274-
* If fcall is not NULL, ownership was NOT taken by
1275-
* coroutine_entry_point (coroutine did not start execution).
1276-
* In this case fiber must free fcall.
1277-
*/
1278-
if (fiber->fcall != NULL) {
1279-
zend_fcall_t *fcall = fiber->fcall;
1280-
fiber->fcall = NULL;
1281-
zval_ptr_dtor(&fcall->fci.function_name);
1282-
efree(fcall);
1283-
}
1284-
12851273
if (ZEND_COROUTINE_IS_FINISHED(coroutine)) {
1274+
/*
1275+
* If fcall is not NULL, ownership was NOT taken by
1276+
* coroutine_entry_point (coroutine did not start execution).
1277+
* In this case fiber must free fcall.
1278+
*/
1279+
if (fiber->fcall != NULL) {
1280+
zend_fcall_t *fcall = fiber->fcall;
1281+
fiber->fcall = NULL;
1282+
zval_ptr_dtor(&fcall->fci.function_name);
1283+
efree(fcall);
1284+
}
1285+
12861286
ZEND_ASYNC_EVENT_RELEASE(&coroutine->event);
12871287
return;
12881288
}
@@ -1292,6 +1292,7 @@ static void zend_fiber_object_destroy(zend_object *object)
12921292
);
12931293

12941294
ZEND_ASYNC_CANCEL(coroutine, exception, true);
1295+
ZEND_ASYNC_EVENT_RELEASE(&coroutine->event);
12951296

12961297
return;
12971298
}

0 commit comments

Comments
 (0)