Fix memory leak in GC when rootset enumeration fails (#4793)

Signed-off-by: zhenweijin <zhenwei.jin@intel.com>
This commit is contained in:
Zhenwei Jin 2026-01-26 09:12:23 +08:00 committed by GitHub
parent a60c707a5a
commit 09a2456d7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -308,8 +308,12 @@ reclaim_instance_heap(gc_heap_t *heap)
return GC_SUCCESS;
ret = gct_vm_begin_rootset_enumeration(heap->cluster, heap);
#endif
if (!ret)
if (!ret) {
if (heap->root_set) {
rollback_mark(heap);
}
return GC_ERROR;
}
#if BH_ENABLE_GC_VERIFY != 0
/* no matter whether the enumeration is successful or not, the data