Skip to content

Commit 5802ace

Browse files
committed
php#7: Fixed a bug with incorrect memory release of a microtask.
1 parent 9f3bd23 commit 5802ace

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Zend/zend_gc.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,8 +2034,10 @@ static void zend_gc_collect_cycles_coroutine(void)
20342034
}
20352035

20362036
if (GC_G(microtask) != NULL) {
2037-
GC_G(microtask)->is_cancelled = true;
2038-
ZEND_ASYNC_MICROTASK_RELEASE(GC_G(microtask));
2037+
zend_async_microtask_t *microtask = GC_G(microtask);
2038+
GC_G(microtask) = NULL;
2039+
microtask->is_cancelled = true;
2040+
ZEND_ASYNC_MICROTASK_RELEASE(microtask);
20392041
}
20402042
}
20412043

@@ -2066,8 +2068,10 @@ static void coroutine_dispose(zend_coroutine_t *coroutine)
20662068
GC_G(dtor_scope) = NULL;
20672069

20682070
if (GC_G(microtask) != NULL) {
2069-
GC_G(microtask)->is_cancelled = true;
2070-
zend_gc_collect_cycles_microtask_dtor(GC_G(microtask));
2071+
zend_async_microtask_t *microtask = GC_G(microtask);
2072+
GC_G(microtask) = NULL;
2073+
microtask->is_cancelled = true;
2074+
ZEND_ASYNC_MICROTASK_RELEASE(microtask);
20712075
}
20722076

20732077
if (GC_G(gc_stack) != NULL) {

0 commit comments

Comments
 (0)