diff options
author | nagachika <nagachika@ruby-lang.org> | 2022-04-12 20:08:08 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2022-04-12 20:48:55 +0900 |
commit | 3fa771ddedac25560be57f4055f1767e6c810f58 (patch) | |
tree | 5c2d9df8a1a2fdb3ff38f878308757d96cd88746 /test/ruby/test_float.rb | |
parent | 052ec6d2585c3ace95671013d336f5543624ef3d (diff) |
Fix dtoa buffer overrunv3_0_4
Diffstat (limited to 'test/ruby/test_float.rb')
-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 fbf0d87f8e..b218b72db5 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 |