зеркало из https://github.com/github/ruby.git
* string.c (rb_str_concat): use memcpy to copy a string which contains
NUL characters. [ruby-core:47751] [Bug #7090] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
4d4800a5a7
Коммит
64989fa5a2
|
@ -1,3 +1,8 @@
|
|||
Sun Sep 30 21:18:03 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* 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@gmail.com>
|
||||
|
||||
* test/ruby/envutil.rb (EnvUtil#invoke_ruby): kill child process
|
||||
|
|
2
string.c
2
string.c
|
@ -2158,7 +2158,7 @@ rb_str_concat(VALUE str1, VALUE str2)
|
|||
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);
|
||||
|
|
|
@ -473,6 +473,12 @@ class TestString < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче