diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | gc.c | 10 |
2 files changed, 12 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Tue Nov 16 00:07:32 2010 Yusuke Endoh <mame@tsg.ne.jp> + + * gc.c (assign_heap_slot): fix fear of memory leak and memory + violation. Coverity Scan found this bug. + Mon Nov 15 23:54:45 2010 Yusuke Endoh <mame@tsg.ne.jp> * eval_intern.h (CHECK_STACK_OVERFLOW): it was not intended to add @@ -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; |