mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
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]
This commit is contained in:
parent
afb361dfd0
commit
3f9562015e
2 changed files with 17 additions and 3 deletions
|
@ -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 = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue