aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-30 02:33:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-30 02:33:38 +0000
commit950508e9b73543c4ec1846b3b7887613e9defc20 (patch)
tree06323c8c9b41a7e33eeb99e6c1fa113f116303bc
parent361978beb23c00670679252bd9a0f8f9720e618d (diff)
downloadruby-950508e9b73543c4ec1846b3b7887613e9defc20.tar.gz
string.c: reset code range
* string.c (rb_str_substr): need to reset code range for shared string too, not only copied string. [ruby-core:62842] [Bug #9882] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--string.c2
-rw-r--r--test/ruby/test_string.rb2
3 files changed, 9 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 63e4973e7f..c47c094031 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri May 30 11:33:35 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (rb_str_substr): need to reset code range for shared
+ string too, not only copied string.
+ [ruby-core:62842] [Bug #9882]
+
Fri May 30 10:22:21 2014 Mark Lorenz <mlorenz@covermymeds.com>
* lib/erb.rb (result): [DOC] no longer accepts a Proc, as
diff --git a/string.c b/string.c
index c093433736..15e6bcd623 100644
--- a/string.c
+++ b/string.c
@@ -1894,10 +1894,10 @@ rb_str_substr(VALUE str, long beg, long len)
}
else {
str2 = rb_str_new_with_class(str, p, len);
- rb_enc_cr_str_copy_for_substr(str2, str);
OBJ_INFECT(str2, str);
RB_GC_GUARD(str);
}
+ rb_enc_cr_str_copy_for_substr(str2, str);
return str2;
}
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 6581796a94..0fd49d232d 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -894,6 +894,8 @@ class TestString < Test::Unit::TestCase
assert_not_equal(S("a").hash, S("a\0").hash, bug4104)
bug9172 = '[ruby-core:58658] [Bug #9172]'
assert_not_equal(S("sub-setter").hash, S("discover").hash, bug9172)
+ bug9882 = '[ruby-core:62842] [Bug #9882]'
+ assert_equal(S(bug9882).hash, S("\u{30c6 30b9 30c8 2019}#{bug9882}")[4..-1].hash, bug9882)
end
def test_hash_random