From 955849c126dedaab1d5f3a5467f3daf3da16d14d Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 4 May 2018 06:12:12 +0000 Subject: 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/trunk@63334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_float.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/ruby/test_float.rb') diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 5686fd4617..3453440694 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -165,6 +165,12 @@ class TestFloat < Test::Unit::TestCase end assert_equal(1.0e10, Float("1.0_"+"00000"*Float::DIG+"e10")) + + z = "0" * (Float::DIG * 4 + 10) + all_assertions_foreach("long invalid string", "1.0", "1.0e", "1.0e-", "1.0e+") 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