diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-10 05:48:38 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-10 05:48:38 +0000 |
commit | 2667d1b38f39390d9c3bb90c5257ffb9723e1c77 (patch) | |
tree | cc4ef8e453688521d56d655699ed4900bc7b4ea4 /test/ruby/test_env.rb | |
parent | f9843bc4dcc9b7313ed5a631390c502a894f2f82 (diff) |
hash.c: ensure NUL-terminated for ENV
* hash.c (get_env_cstr): ensure NUL-terminated.
[ruby-dev:49655] [Bug #12475]
* string.c (rb_str_fill_terminator): return the pointer to the
NUL-terminated content.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_env.rb')
-rw-r--r-- | test/ruby/test_env.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb index b14ea22996..17323ccf95 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -455,6 +455,20 @@ class TestEnv < Test::Unit::TestCase end end + def test_shared_substring + bug12475 = '[ruby-dev:49655] [Bug #12475]' + n = [*"0".."9"].join("")*3 + e0 = ENV[n0 = "E#{n}"] + e1 = ENV[n1 = "E#{n}."] + ENV[n0] = nil + ENV[n1] = nil + ENV[n1.chop] = "T#{n}.".chop + ENV[n0], e0 = e0, ENV[n0] + ENV[n1], e1 = e1, ENV[n1] + assert_equal("T#{n}", e0, bug12475) + assert_nil(e1, bug12475) + end + if RUBY_PLATFORM =~ /bccwin|mswin|mingw/ def test_memory_leak_aset bug9977 = '[ruby-dev:48323] [Bug #9977]' |