From 88c68a89d3bfae15664f59355c013c0c23bd1a63 Mon Sep 17 00:00:00 2001 From: usa Date: Tue, 27 Dec 2016 10:11:49 +0000 Subject: merge revision(s) 56894: [Backport #12974] 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/branches/ruby_2_2@57211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_marshal.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index ef987cc7fa..1dc9850d25 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -671,4 +671,16 @@ class TestMarshal < Test::Unit::TestCase end RUBY 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 -- cgit v1.2.3