[前][次][番号順一覧][スレッド一覧]

ruby-changes:17791

From: mame <ko1@a...>
Date: Tue, 16 Nov 2010 00:09:49 +0900 (JST)
Subject: [ruby-changes:17791] Ruby:r29801 (trunk): * gc.c (assign_heap_slot): fix fear of memory leak and memory

mame	2010-11-16 00:09:40 +0900 (Tue, 16 Nov 2010)

  New Revision: 29801

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29801

  Log:
    * gc.c (assign_heap_slot): fix fear of memory leak and memory
      violation.  Coverity Scan found this bug.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29800)
+++ ChangeLog	(revision 29801)
@@ -1,3 +1,8 @@
+Tue Nov 16 00:07:32 2010  Yusuke Endoh  <mame@t...>
+
+	* 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@t...>
 
 	* eval_intern.h (CHECK_STACK_OVERFLOW): it was not intended to add
Index: gc.c
===================================================================
--- gc.c	(revision 29800)
+++ gc.c	(revision 29801)
@@ -924,13 +924,17 @@
 
     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;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]