From 1dd06612a5fe377d191f5d88ffd598d9f39d6f1b Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 19 Apr 2013 04:03:29 +0000 Subject: marshal.c: no duplicated encoding * marshal.c (w_object): do not dump encoding which is dumped with marshal_dump data. [ruby-core:54334] [Bug #8276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_marshal.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index 722871424d..baf143bcfb 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -539,6 +539,24 @@ class TestMarshal < Test::Unit::TestCase assert_nil(loaded.foo, bug7627) end + class Bug8276 + attr_reader :data + def initialize(data) + @data = data + freeze + end + alias marshal_dump data + alias marshal_load initialize + end + + def test_marshal_dump_excess_encoding + bug8276 = '[ruby-core:54334] [Bug #8276]' + t = Bug8276.new(bug8276) + s = Marshal.dump(t) + assert_nothing_raised(RuntimeError) {s = Marshal.load(s)} + assert_equal(t.data, s.data, bug8276) + end + def test_class_ivar assert_raise(TypeError) {Marshal.load("\x04\x08Ic\x1bTestMarshal::TestClass\x06:\x0e@ivar_bug\"\x08bug")} assert_raise(TypeError) {Marshal.load("\x04\x08IM\x1bTestMarshal::TestClass\x06:\x0e@ivar_bug\"\x08bug")} -- cgit v1.2.3