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

ruby-changes:46531

From: nobu <ko1@a...>
Date: Wed, 10 May 2017 23:25:09 +0900 (JST)
Subject: [ruby-changes:46531] nobu:r58652 (trunk): gc.c: check of size in ruby_sized_xrealloc

nobu	2017-05-10 23:25:03 +0900 (Wed, 10 May 2017)

  New Revision: 58652

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58652

  Log:
    gc.c: check of size in ruby_sized_xrealloc

  Modified files:
    trunk/gc.c
Index: gc.c
===================================================================
--- gc.c	(revision 58651)
+++ gc.c	(revision 58652)
@@ -7880,7 +7880,7 @@ objspace_xrealloc(rb_objspace_t *objspac https://github.com/ruby/ruby/blob/trunk/gc.c#L7880
 {
     void *mem;
 
-    if (!ptr) return objspace_xmalloc(objspace, new_size);
+    if (!ptr) return objspace_xmalloc0(objspace, new_size);
 
     /*
      * The behavior of realloc(ptr, 0) is implementation defined.
@@ -7979,6 +7979,10 @@ ruby_xcalloc(size_t n, size_t size) https://github.com/ruby/ruby/blob/trunk/gc.c#L7979
 void *
 ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size)
 {
+    if ((ssize_t)new_size < 0) {
+	negative_size_allocation_error("too large allocation size");
+    }
+
     return objspace_xrealloc(&rb_objspace, ptr, new_size, old_size);
 }
 

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

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