From 4c2f9198197ead6da0c87d8bff518e78fd3a36d4 Mon Sep 17 00:00:00 2001 From: usa Date: Thu, 31 Jan 2019 10:47:59 +0000 Subject: merge revision(s) 63334: [Backport #14729] object.c: raise on long invalid float string * object.c (rb_cstr_to_dbl_raise): check long invalid float string more precisely when truncating insignificant part. [ruby-core:86800] [Bug #14729] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@66962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_float.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index fcff9fc7b8..d873461de1 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -163,6 +163,12 @@ class TestFloat < Test::Unit::TestCase assert_equal(-31.0*2**-1027, Float("-0x1f"+("0"*268)+".0p-2099")) assert_equal(-31.0*2**-1027, Float("-0x1f"+("0"*600)+".0p-3427")) end + + z = "0" * (Float::DIG * 4 + 10) + ["long invalid string", "1.0", "1.0e", "1.0e-", "1.0e+"].each do |n| + assert_raise(ArgumentError, n += z + "A") {Float(n)} + assert_raise(ArgumentError, n += z + ".0") {Float(n)} + end end def test_divmod -- cgit v1.2.3