diff --git a/src/gc.c b/src/gc.c index dad338ae..72190d00 100644 --- a/src/gc.c +++ b/src/gc.c @@ -139,8 +139,7 @@ gc_alloc(pic_state *pic, size_t size) if (p->s.size >= nunits) break; if (p == freep) { - if ((p = add_heap_page(pic)) == NULL) - return NULL; + return NULL; } } if (p->s.size == nunits) { @@ -494,8 +493,11 @@ pic_obj_alloc_unsafe(pic_state *pic, size_t size, enum pic_tt tt) if (obj == NULL) { pic_gc_run(pic); obj = (struct pic_object *)gc_alloc(pic, size); - if (obj == NULL) - pic_abort(pic, "GC memory exhausted"); + if (obj == NULL) { + if (add_heap_page(pic) == NULL) + pic_abort(pic, "GC memory exhausted"); + obj = (struct pic_object *)gc_alloc(pic, size); + } } obj->tt = tt;