mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
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
This commit is contained in:
parent
80aa1e6218
commit
f5052d45be
2 changed files with 10 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue