summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-26 02:37:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-26 02:37:51 +0000
commit622f3f14b6928ee4fe3afa96db0250eb9da32e7a (patch)
treed0499f6a89c3ef88c857143f786425ec4279bc1e /test
parent73b59166d214719531d7228996d6a322a1518922 (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/-ext-/string/test_cstr.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/-ext-/string/test_cstr.rb b/test/-ext-/string/test_cstr.rb
index 6f2fdef..72a9dd6 100644
--- a/test/-ext-/string/test_cstr.rb
+++ b/test/-ext-/string/test_cstr.rb
@@ -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|