diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-04-27 21:21:55 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-04-27 21:26:42 +0900 |
commit | 3f9562015e651735bfc2fdd14e8f6963b673e22a (patch) | |
tree | e3b5107346fcd0bbff7576bd2f511f90194dc1d3 /test | |
parent | afb361dfd0811f96f601d8d6492f9e1a0321ea01 (diff) | |
download | ruby-3f9562015e651735bfc2fdd14e8f6963b673e22a.tar.gz |
Get rid of indirect sharing
* string.c (str_duplicate): share the root shared string if the
original string is already sharing, so that all shared strings
refer the root shared string directly. indirect sharing can
cause a dangling pointer.
[Bug #15792]
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_string.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index d94c4da7ae..f591f7ea9d 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -2961,6 +2961,15 @@ CODE end =end + def test_nesting_shared + a = ('a' * 24).encode(Encoding::ASCII).gsub('x', '') + hash = {} + hash[a] = true + assert_equal(('a' * 24), a) + 4.times { GC.start } + assert_equal(('a' * 24), a, '[Bug #15792]') + end + def test_shared_force_encoding s = "\u{3066}\u{3059}\u{3068}".gsub(//, '') h = {} |