aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_marshal.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-24 11:07:12 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-24 11:07:12 +0000
commitdd3b41206e097b7afef73cab683453f52b22d297 (patch)
tree759cf967b5679014363e84e2b88d01e56563b88f /test/ruby/test_marshal.rb
parent4632363ea5453593ab6582d3d2793aa5445d5ac4 (diff)
downloadruby-dd3b41206e097b7afef73cab683453f52b22d297.tar.gz
marshal.c: fix infinite recursion
* marshal.c (check_userdump_arg): marshal_dump should not return an instance of the same class, otherwise it causes infinite recursion. [ruby-core:78289] [Bug #12974] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_marshal.rb')
-rw-r--r--test/ruby/test_marshal.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index d21ab66ffd..bc22b5fd3a 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -757,4 +757,16 @@ class TestMarshal < Test::Unit::TestCase
end
assert_equal(obj, Marshal.load(dump))
end
+
+ class Bug12974
+ def marshal_dump
+ dup
+ end
+ end
+
+ def test_marshal_dump_recursion
+ assert_raise_with_message(RuntimeError, /same class instance/) do
+ Marshal.dump(Bug12974.new)
+ end
+ end
end