diff options
author | NAKAMURA Usaku <usa@ruby-lang.org> | 2022-04-12 20:25:48 +0900 |
---|---|---|
committer | NAKAMURA Usaku <usa@ruby-lang.org> | 2022-04-12 20:25:48 +0900 |
commit | c9c2245c0a25176072e02db9254f0e0c84c805cd (patch) | |
tree | 61e80059a35598b3b2da400de2f6ff366fa1a89e /test | |
parent | 389723d85433df0b487f02c94ca6a243d39a189e (diff) |
Fix dtoa buffer overrunv2_7_6
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_float.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 7cbf3b5a8f..9c24dac8e6 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -171,6 +171,24 @@ class TestFloat < Test::Unit::TestCase assert_raise(ArgumentError, n += z + "A") {Float(n)} assert_raise(ArgumentError, n += z + ".0") {Float(n)} end + + x = nil + 2000.times do + x = Float("0x"+"0"*30) + break unless x == 0.0 + end + assert_equal(0.0, x, ->{"%a" % x}) + x = nil + 2000.times do + begin + x = Float("0x1."+"0"*270) + rescue ArgumentError => e + raise unless /"0x1\.0{270}"/ =~ e.message + else + break + end + end + assert_nil(x, ->{"%a" % x}) end def test_divmod |