From 5b4d95b8d03b17c80f2b54a1e92b74df2bb9f63e Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 15 Apr 2026 08:09:56 +0200 Subject: [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 --- test/json/json_ryu_fallback_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') 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 -- cgit v1.2.3