diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-19 17:23:27 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-19 17:23:27 +0000 |
commit | 7d7aec241381d11317c16115f6592a0d3c6b7fce (patch) | |
tree | 083a5fdf401d5d1e4daf0fe63b941e86883d8224 | |
parent | 39b89ceeb4a875f12ed90278d291f5ea9135f35a (diff) |
merge revision(s) 49859,49861,49865: [Backport #10941] [Backport #10978] [Backport #11089]
* dir.c (replace_real_basename): shouldn't create Ruby object before
the object system is loaded.
[ruby-core:68430] [Bug #10941]
* dir.c (replace_real_basename): need to check the return value of
GLOB_REALLOC().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@50545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | dir.c | 34 | ||||
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 8 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 48 insertions, 7 deletions
@@ -1,3 +1,14 @@ +Wed May 20 02:16:05 2015 NAKAMURA Usaku <usa@ruby-lang.org> + + * dir.c (replace_real_basename): need to check the return value of + GLOB_REALLOC(). + +Wed May 20 02:16:05 2015 NAKAMURA Usaku <usa@ruby-lang.org> + + * dir.c (replace_real_basename): shouldn't create Ruby object before + the object system is loaded. + [ruby-core:68430] [Bug #10941] + Wed May 20 01:58:12 2015 Tanaka Akira <akr@fsij.org> * lib/resolv.rb (Resolv::DNS::Label::Str#==): Check class equality. @@ -1481,12 +1481,34 @@ replace_real_basename(char *path, long base, rb_encoding *enc, int norm_p) free(wplain); if (h == INVALID_HANDLE_VALUE) return path; FindClose(h); - tmp = rb_w32_conv_from_wchar(fd.cFileName, enc); - wlen = RSTRING_LEN(tmp); - path = GLOB_REALLOC(path, base + wlen + 1); - memcpy(path + base, RSTRING_PTR(tmp), wlen); - path[base + wlen] = 0; - rb_str_resize(tmp, 0); + if (tmp) { + char *buf; + tmp = rb_w32_conv_from_wchar(fd.cFileName, enc); + wlen = RSTRING_LEN(tmp); + 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); + } + } return path; } #elif USE_NAME_ON_FS == 1 diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 8d3da54997..7cb1248e53 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -720,6 +720,14 @@ class TestRubyOptions < Test::Unit::TestCase bug10555, encoding: "locale") end end + + def test_command_line_glob_with_dir + bug10941 = '[ruby-core:68430] [Bug #10941]' + with_tmpchdir do |dir| + Dir.mkdir('test') + assert_in_out_err(["-e", "", "test/*"], "", [], [], bug10941) + end + end end if /mswin|mingw/ =~ RUBY_PLATFORM @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.2.3" #define RUBY_RELEASE_DATE "2015-05-20" -#define RUBY_PATCHLEVEL 104 +#define RUBY_PATCHLEVEL 105 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 5 |