summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2026-04-15 08:09:56 +0200
committergit <svn-admin@ruby-lang.org>2026-04-15 06:21:08 +0000
commit5b4d95b8d03b17c80f2b54a1e92b74df2bb9f63e (patch)
tree0132b0e13bee1d22944219279c526b7ac5c8c732 /test
parentb21043f8ac1aa2aeaaadae4153f4e059aedaf988 (diff)
[ruby/json] Fix handling out of of range exponent in numbers
Fix: https://github.com/ruby/json/issues/970 If the parsed exponent overflows a `int32_t` passing it to ryu is incorrect. We could pass it to `rb_cstr_to_dbl` but then Ruby will emit an annoying warning, instead we can coerce to `0.0` and `Inf`. https://github.com/ruby/json/commit/20454ba274
Diffstat (limited to 'test')
-rw-r--r--test/json/json_ryu_fallback_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/json/json_ryu_fallback_test.rb b/test/json/json_ryu_fallback_test.rb
index 59ba76d392..dc60067b91 100644
--- a/test/json/json_ryu_fallback_test.rb
+++ b/test/json/json_ryu_fallback_test.rb
@@ -166,4 +166,12 @@ class JSONRyuFallbackTest < Test::Unit::TestCase
end
end
end
+
+ def test_large_exponent_numbers
+ assert_equal Float::INFINITY, JSON.parse("1e4294967296")
+ assert_equal 0.0, JSON.parse("1e-4294967296")
+ assert_equal 0.0, JSON.parse("99999999999999999e-4294967296")
+ assert_equal Float::INFINITY, JSON.parse("1e4294967295")
+ assert_equal Float::INFINITY, JSON.parse("1e4294967297")
+ end
end