From 7708215b609733bcfa06074b67463920c03782e8 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sat, 25 Apr 2015 00:13:09 +0800 Subject: [PATCH] Try to fix #313 again --- include/rapidjson/reader.h | 2 +- test/unittest/readertest.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index d809d57..be0d9fb 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -928,7 +928,7 @@ private: if (expMinus) { while (s.Peek() >= '0' && s.Peek() <= '9') { exp = exp * 10 + (s.Take() - '0'); - if (exp >= 429496729) { // Issue #313: prevent overflow exponent + if (exp >= 214748364) { // Issue #313: prevent overflow exponent while (s.Peek() >= '0' && s.Peek() <= '9') // Consume the rest of exponent s.Take(); } diff --git a/test/unittest/readertest.cpp b/test/unittest/readertest.cpp index e55380c..bee19a8 100644 --- a/test/unittest/readertest.cpp +++ b/test/unittest/readertest.cpp @@ -228,9 +228,10 @@ static void TestParseDouble() { TEST_DOUBLE(fullPrecision, "2.2250738585072011e-308", 2.2250738585072011e-308); // http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/ TEST_DOUBLE(fullPrecision, "1e-00011111111111", 0.0); // Issue #313 TEST_DOUBLE(fullPrecision, "-1e-00011111111111", -0.0); - TEST_DOUBLE(fullPrecision, "1e-429496729", 0.0); // Maximum supported negative exponent + TEST_DOUBLE(fullPrecision, "1e-214748363", 0.0); // Maximum supported negative exponent + TEST_DOUBLE(fullPrecision, "1e-214748364", 0.0); + TEST_DOUBLE(fullPrecision, "1e-21474836311", 0.0); TEST_DOUBLE(fullPrecision, "0.017976931348623157e+310", 1.7976931348623157e+308); // Max double in another form - // Since // abs((2^-1022 - 2^-1074) - 2.2250738585072012e-308) = 3.109754131239141401123495768877590405345064751974375599... กม 10^-324