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

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
This commit is contained in:
nobu 2014-12-26 05:48:12 +00:00
parent aac77886b3
commit ea9ff28f80
3 changed files with 17 additions and 4 deletions

View file

@ -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);