diff --git a/api/gc-api.h b/api/gc-api.h index c95c33a65..58f40b779 100644 --- a/api/gc-api.h +++ b/api/gc-api.h @@ -140,6 +140,7 @@ static inline void* gc_allocate_small_fast_freelist(struct gc_mutator *mut, return NULL; *freelist_loc = *(void**)head; + *(void**)head = NULL; gc_update_alloc_table(gc_ref_from_heap_object(head), size, kind); diff --git a/src/bdw.c b/src/bdw.c index 3e7bcf17c..886e70718 100644 --- a/src/bdw.c +++ b/src/bdw.c @@ -122,6 +122,7 @@ allocate_small(void **freelist, size_t idx, enum gc_inline_kind kind) { } *freelist = *(void **)(head); + *(void**)head = NULL; if (kind == GC_INLINE_KIND_POINTERLESS) memset(head, 0, gc_inline_freelist_object_size(idx));