aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_marshal.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-01 16:20:03 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-01 16:20:03 +0900
commit78ee2c245331e353e218b8fac9ca722a2bcd8fea (patch)
treee1e3ce2747384d7c422c26cd48c2a380bc3cf939 /test/ruby/test_marshal.rb
parent0b1e26398e018116180bf41cb63887f77d5d1b82 (diff)
downloadruby-78ee2c245331e353e218b8fac9ca722a2bcd8fea.tar.gz
marshal.c: check instance variable count
* marshal.c (w_ivar_each): ensure that no instance variable was removed while dumping other instance variables. [Bug #15968]
Diffstat (limited to 'test/ruby/test_marshal.rb')
-rw-r--r--test/ruby/test_marshal.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index 0565a1c04f..f6d84d181a 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -795,7 +795,11 @@ class TestMarshal < Test::Unit::TestCase
end
def marshal_dump
- self.foo.baz = :problem
+ if self.foo.baz
+ self.foo.remove_instance_variable(:@baz)
+ else
+ self.foo.baz = :problem
+ end
{foo: self.foo}
end
@@ -811,4 +815,12 @@ class TestMarshal < Test::Unit::TestCase
Marshal.dump(obj)
end
end
+
+ def test_marshal_dump_removing_instance_variable
+ obj = Bug15968.new
+ obj.baz = :Bug15968
+ assert_raise_with_message(RuntimeError, /instance variable removed/) do
+ Marshal.dump(obj)
+ end
+ end
end