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

ruby-changes:36942

From: nobu <ko1@a...>
Date: Fri, 26 Dec 2014 14:48:19 +0900 (JST)
Subject: [ruby-changes:36942] nobu:r49023 (trunk): win32: realloc failures

nobu	2014-12-26 14:48:12 +0900 (Fri, 26 Dec 2014)

  New Revision: 49023

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

  Log:
    win32: realloc failures
    
    * win32/file.c (code_page_i): handle realloc failure.
      reported by Denis Denisov <denji0k AT gmail.com>.
    * win32/stub.c (stub_sysinit): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/win32/file.c
    trunk/win32/stub.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49022)
+++ ChangeLog	(revision 49023)
@@ -1,4 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Fri Dec 26 14:33:01 2014  Nobuyoshi Nakada  <nobu@r...>
+Fri Dec 26 14:48:10 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/file.c (code_page_i): handle realloc failure.
+	  reported by Denis Denisov <denji0k AT gmail.com>.
+
+	* win32/stub.c (stub_sysinit): ditto.
 
 	* fix printf format conversion specifiers.
 	  reported by Denis Denisov <denji0k AT gmail.com>.
Index: win32/stub.c
===================================================================
--- win32/stub.c	(revision 49022)
+++ win32/stub.c	(revision 49023)
@@ -21,7 +21,12 @@ stub_sysinit(int *argc, char ***argv) https://github.com/ruby/ruby/blob/trunk/win32/stub.c#L21
     for (i = 1; i < ac; ++i) {
 	lenall += strlen(av[i]) + 1;
     }
-    *argv = av = realloc(av, lenall + (lenexe + 1) * 2 + sizeof(char *) * (i + 2));
+    av = realloc(av, lenall + (lenexe + 1) * 2 + sizeof(char *) * (i + 2));
+    if (!av) {
+	perror("realloc command line");
+	exit(-1);
+    }
+    *argv = av;
     *argc = ++ac;
     p = (char *)(av + i + 2);
     memmove(p + (lenexe + 1) * 2, (char *)(av + ac) + len0, lenall);
Index: win32/file.c
===================================================================
--- win32/file.c	(revision 49022)
+++ win32/file.c	(revision 49023)
@@ -160,8 +160,11 @@ code_page_i(st_data_t name, st_data_t id https://github.com/ruby/ruby/blob/trunk/win32/file.c#L160
 	    USHORT *table = cp->table;
 	    if (count <= idx) {
 		unsigned int i = count;
-		cp->count = count = (((idx + 4) & ~31) | 28);
-		cp->table = table = realloc(table, count * sizeof(*table));
+		count = (((idx + 4) & ~31) | 28);
+		table = realloc(table, count * sizeof(*table));
+		if (!table) return ST_CONTINUE;
+		cp->count = count;
+		cp->table = table;
 		while (i < count) table[i++] = INVALID_CODE_PAGE;
 	    }
 	    table[idx] = (USHORT)code_page;

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

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