1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* gc.c (assign_heap_slot): fix fear of memory leak and memory

violation.  Coverity Scan found this bug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2010-11-15 15:09:40 +00:00
parent 9ffd060b30
commit 4c17014bf3
2 changed files with 13 additions and 4 deletions

View file

@ -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> 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 * eval_intern.h (CHECK_STACK_OVERFLOW): it was not intended to add

12
gc.c
View file

@ -924,13 +924,17 @@ assign_heap_slot(rb_objspace_t *objspace)
objs = HEAP_OBJ_LIMIT; objs = HEAP_OBJ_LIMIT;
p = (RVALUE*)malloc(HEAP_SIZE); p = (RVALUE*)malloc(HEAP_SIZE);
slot = (struct heaps_slot *)malloc(sizeof(struct heaps_slot)); if (p == 0) {
MEMZERO((void*)slot, struct heaps_slot, 1);
if (p == 0 || slot == 0) {
during_gc = 0; during_gc = 0;
rb_memerror(); rb_memerror();
} }
slot = (struct heaps_slot *)malloc(sizeof(struct heaps_slot));
if (slot == 0) {
xfree(p);
during_gc = 0;
rb_memerror();
}
MEMZERO((void*)slot, struct heaps_slot, 1);
slot->next = heaps; slot->next = heaps;
if (heaps) heaps->prev = slot; if (heaps) heaps->prev = slot;