aboutsummaryrefslogtreecommitdiffstats
path: root/win32/stub.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-26 05:48:12 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-26 05:48:12 +0000
commitea9ff28f80165ec054106702ee38f5995bc4a491 (patch)
treed3559a1a191a898f816ac5adf56f1310a920142d /win32/stub.c
parentaac77886b318d2272d0bce29cede4566332ea205 (diff)
downloadruby-ea9ff28f80165ec054106702ee38f5995bc4a491.tar.gz
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/stub.c')
-rw-r--r--win32/stub.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/win32/stub.c b/win32/stub.c
index fc82d73e2c..3960024fc2 100644
--- a/win32/stub.c
+++ b/win32/stub.c
@@ -21,7 +21,12 @@ stub_sysinit(int *argc, char ***argv)
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);