mirror of
https://github.com/ruby/ruby.git
synced 2025-09-19 10:33:58 +02:00
* complex.c (nucomp_marshal_load): raise error on invalid data.
reported by John Firebaugh [ruby-core:42860] [Bug #6076] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
57657a0b9b
commit
eeff98c430
4 changed files with 23 additions and 0 deletions
|
@ -469,4 +469,18 @@ class TestMarshal < Test::Unit::TestCase
|
|||
assert_equal(o1.class, o2.class)
|
||||
assert_equal(o1.foo, o2.foo)
|
||||
end
|
||||
|
||||
def test_marshal_complex
|
||||
assert_raise(ArgumentError){Marshal.load("\x04\bU:\fComplex[\x05")}
|
||||
assert_raise(ArgumentError){Marshal.load("\x04\bU:\fComplex[\x06i\x00")}
|
||||
assert_equal(Complex(1, 2), Marshal.load("\x04\bU:\fComplex[\ai\x06i\a"))
|
||||
assert_raise(ArgumentError){Marshal.load("\x04\bU:\fComplex[\bi\x00i\x00i\x00")}
|
||||
end
|
||||
|
||||
def test_marshal_rational
|
||||
assert_raise(ArgumentError){Marshal.load("\x04\bU:\rRational[\x05")}
|
||||
assert_raise(ArgumentError){Marshal.load("\x04\bU:\rRational[\x06i\x00")}
|
||||
assert_equal(Rational(1, 2), Marshal.load("\x04\bU:\rRational[\ai\x06i\a"))
|
||||
assert_raise(ArgumentError){Marshal.load("\x04\bU:\rRational[\bi\x00i\x00i\x00")}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue