summaryrefslogtreecommitdiff
path: root/test/ruby/test_rational.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-11 07:26:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-11 07:26:14 +0000
commite41ebc50dc27f5b91690295e0db8eaf45da42630 (patch)
tree0828897db636a282cae3030587ebd0fd6e80aadb /test/ruby/test_rational.rb
parent0f9ce57b86f5e65912bf113b96d49642aecbfe24 (diff)
rational.c: check load
* rational.c (nurat_loader, nurat_marshal_load): check if loading values are Integer. [ruby-core:78071] [Bug #12918] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_rational.rb')
-rw-r--r--test/ruby/test_rational.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index d65c292970..834188e4d8 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -646,6 +646,10 @@ class Rational_Test < Test::Unit::TestCase
assert_equal(9, c2.instance_variable_get(:@ivar))
assert_instance_of(Rational, c2)
+ assert_raise(TypeError){
+ Marshal.load("\x04\bU:\rRational[\ai\x060")
+ }
+
assert_raise(ZeroDivisionError){
Marshal.load("\x04\bU:\rRational[\ai\x06i\x05")
}
@@ -664,6 +668,10 @@ class Rational_Test < Test::Unit::TestCase
assert_nothing_raised(bug6625) do
assert_equal(Rational(1, 2), Marshal.load(dump), bug6625)
end
+ dump = "\x04\x08o:\x0dRational\x07:\x11@denominatori\x07:\x0f@numerator0"
+ assert_raise(TypeError) do
+ Marshal.load(dump)
+ end
end
def test_parse