mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 13:04:13 +02:00
string.c: terminate when embedded
* string.c (str_make_independent_expand): terminate String when moved from heap to embedded. [Fix GH-821]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
73b59166d2
commit
622f3f14b6
3 changed files with 15 additions and 0 deletions
|
@ -86,6 +86,15 @@ class Test_StringCStr < Test::Unit::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_embedded_from_heap
|
||||
gh821 = "[GH-821]"
|
||||
embedded_string = "abcdefghi"
|
||||
string = embedded_string.gsub("efg", "123")
|
||||
{}[string] = 1
|
||||
non_terminated = "#{string}#{nil}"
|
||||
assert_nil(Bug::String.cstr_term_char(non_terminated), gh821)
|
||||
end
|
||||
|
||||
def assert_wchars_term_char(str)
|
||||
result = {}
|
||||
WCHARS.map do |enc|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue