ruby-changes:25006
From: naruse <ko1@a...>
Date: Sun, 30 Sep 2012 21:20:22 +0900 (JST)
Subject: [ruby-changes:25006] naruse:r37058 (trunk): * string.c (rb_str_concat): use memcpy to copy a string which contains
naruse 2012-09-30 21:20:09 +0900 (Sun, 30 Sep 2012) New Revision: 37058 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37058 Log: * string.c (rb_str_concat): use memcpy to copy a string which contains NUL characters. [ruby-core:47751] [Bug #7090] Modified files: trunk/ChangeLog trunk/string.c trunk/test/ruby/test_string.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 37057) +++ ChangeLog (revision 37058) @@ -1,3 +1,8 @@ +Sun Sep 30 21:18:03 2012 NARUSE, Yui <naruse@r...> + + * string.c (rb_str_concat): use memcpy to copy a string which contains + NUL characters. [ruby-core:47751] [Bug #7090] + Sat Sep 29 19:41:53 2012 Hiroshi Shirosaki <h.shirosaki@g...> * test/ruby/envutil.rb (EnvUtil#invoke_ruby): kill child process Index: string.c =================================================================== --- string.c (revision 37057) +++ string.c (revision 37058) @@ -2158,7 +2158,7 @@ rb_raise(rb_eRangeError, "invalid codepoint 0x%X in %s", code, rb_enc_name(enc)); } rb_str_resize(str1, pos+len); - strncpy(RSTRING_PTR(str1) + pos, buf, len); + memcpy(RSTRING_PTR(str1) + pos, buf, len); if (cr == ENC_CODERANGE_7BIT && code > 127) cr = ENC_CODERANGE_VALID; ENC_CODERANGE_SET(str1, cr); Index: test/ruby/test_string.rb =================================================================== --- test/ruby/test_string.rb (revision 37057) +++ test/ruby/test_string.rb (revision 37058) @@ -473,6 +473,12 @@ def test_concat assert_equal(S("world!"), S("world").concat(33)) assert_equal(S("world!"), S("world").concat(S('!'))) + + bug7090 = '[ruby-core:47751]' + result = S("").force_encoding(Encoding::UTF_16LE) + result << 0x0300 + expected = S("\u0300".encode(Encoding::UTF_16LE)) + assert_equal(expected, result, bug7090) end def test_count -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/