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:
parent
aac77886b3
commit
ea9ff28f80
3 changed files with 17 additions and 4 deletions
|
@ -1,4 +1,9 @@
|
||||||
Fri Dec 26 14:33:01 2014 Nobuyoshi Nakada <nobu@ruby.local>
|
Fri Dec 26 14:48:10 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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.
|
* fix printf format conversion specifiers.
|
||||||
reported by Denis Denisov <denji0k AT gmail.com>.
|
reported by Denis Denisov <denji0k AT gmail.com>.
|
||||||
|
|
|
@ -160,8 +160,11 @@ code_page_i(st_data_t name, st_data_t idx, st_data_t arg)
|
||||||
USHORT *table = cp->table;
|
USHORT *table = cp->table;
|
||||||
if (count <= idx) {
|
if (count <= idx) {
|
||||||
unsigned int i = count;
|
unsigned int i = count;
|
||||||
cp->count = count = (((idx + 4) & ~31) | 28);
|
count = (((idx + 4) & ~31) | 28);
|
||||||
cp->table = table = realloc(table, count * sizeof(*table));
|
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;
|
while (i < count) table[i++] = INVALID_CODE_PAGE;
|
||||||
}
|
}
|
||||||
table[idx] = (USHORT)code_page;
|
table[idx] = (USHORT)code_page;
|
||||||
|
|
|
@ -21,7 +21,12 @@ stub_sysinit(int *argc, char ***argv)
|
||||||
for (i = 1; i < ac; ++i) {
|
for (i = 1; i < ac; ++i) {
|
||||||
lenall += strlen(av[i]) + 1;
|
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;
|
*argc = ++ac;
|
||||||
p = (char *)(av + i + 2);
|
p = (char *)(av + i + 2);
|
||||||
memmove(p + (lenexe + 1) * 2, (char *)(av + ac) + len0, lenall);
|
memmove(p + (lenexe + 1) * 2, (char *)(av + ac) + len0, lenall);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue