aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/gc.c b/gc.c
index b8c8c36684..cf9107ab8e 100644
--- a/gc.c
+++ b/gc.c
@@ -924,13 +924,17 @@ assign_heap_slot(rb_objspace_t *objspace)
objs = HEAP_OBJ_LIMIT;
p = (RVALUE*)malloc(HEAP_SIZE);
+ if (p == 0) {
+ during_gc = 0;
+ rb_memerror();
+ }
slot = (struct heaps_slot *)malloc(sizeof(struct heaps_slot));
- MEMZERO((void*)slot, struct heaps_slot, 1);
-
- if (p == 0 || slot == 0) {
+ if (slot == 0) {
+ xfree(p);
during_gc = 0;
rb_memerror();
}
+ MEMZERO((void*)slot, struct heaps_slot, 1);
slot->next = heaps;
if (heaps) heaps->prev = slot;