summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-18 04:38:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-18 04:38:01 +0000
commitf5052d45be1b564a683c347dd72fd2f7b8638fd8 (patch)
tree0a1b9c32f17af390e4d7405892de0ec473dc56e7 /test
parent80aa1e6218305b2f75c47af368506a7f930f1214 (diff)
string.c: check just before modification
* string.c (rb_str_chomp_bang): check if modifiable after checking an argument and just before modification, as it can get frozen during the argument conversion to String. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_string.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index dc76b53810..0fd0538d00 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -444,6 +444,14 @@ CODE
s = S("").freeze
assert_raise_with_message(RuntimeError, /frozen/) {s.chomp!}
+
+ s = S("ax")
+ o = Struct.new(:s).new(s)
+ def o.to_str
+ s.freeze
+ "x"
+ end
+ assert_raise_with_message(RuntimeError, /frozen/) {s.chomp!(o)}
ensure
$/ = save
end