mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* dir.c (replace_real_basename): need to check the return value of
GLOB_REALLOC(). [ruby-core:68430] [Bug #10941] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7f342f5e99
commit
908c25341e
2 changed files with 23 additions and 6 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Mar 6 02:50:12 2015 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* dir.c (replace_real_basename): need to check the return value of
|
||||
GLOB_REALLOC().
|
||||
|
||||
Fri Mar 6 02:26:03 2015 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* dir.c (replace_real_basename): shouldn't create Ruby object before
|
||||
|
|
16
dir.c
16
dir.c
|
@ -1489,21 +1489,33 @@ replace_real_basename(char *path, long base, rb_encoding *enc, int norm_p)
|
|||
if (h == INVALID_HANDLE_VALUE) return path;
|
||||
FindClose(h);
|
||||
if (tmp) {
|
||||
char *buf;
|
||||
tmp = rb_w32_conv_from_wchar(fd.cFileName, enc);
|
||||
wlen = RSTRING_LEN(tmp);
|
||||
path = GLOB_REALLOC(path, base + wlen + 1);
|
||||
buf = GLOB_REALLOC(path, base + wlen + 1);
|
||||
if (buf) {
|
||||
path = buf;
|
||||
memcpy(path + base, RSTRING_PTR(tmp), wlen);
|
||||
path[base + wlen] = 0;
|
||||
}
|
||||
rb_str_resize(tmp, 0);
|
||||
}
|
||||
else {
|
||||
char *utf8filename;
|
||||
wlen = WideCharToMultiByte(CP_UTF8, 0, fd.cFileName, -1, NULL, 0, NULL, NULL);
|
||||
utf8filename = GLOB_REALLOC(0, wlen);
|
||||
if (utf8filename) {
|
||||
char *buf;
|
||||
WideCharToMultiByte(CP_UTF8, 0, fd.cFileName, -1, utf8filename, wlen, NULL, NULL);
|
||||
buf = GLOB_REALLOC(path, base + wlen + 1);
|
||||
if (buf) {
|
||||
path = buf;
|
||||
memcpy(path + base, utf8filename, wlen);
|
||||
path[base + wlen] = 0;
|
||||
}
|
||||
GLOB_FREE(utf8filename);
|
||||
}
|
||||
path[base + wlen] = 0;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
#elif USE_NAME_ON_FS == 1
|
||||
|
|
Loading…
Reference in a new issue