Commit f5e5d47f authored by abolz's avatar abolz

Properly test for overflow

Do not use an approximation to do this. Instead check if the result is Inf.
parent d83d2ba2
......@@ -1561,8 +1561,6 @@ private:
// Force double for big integer
if (useDouble) {
while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
if (RAPIDJSON_UNLIKELY(d >= 1.7976931348623157e307)) // DBL_MAX / 10.0
RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, startOffset);
d = d * 10 + (s.TakePush() - '0');
}
}
......@@ -1702,6 +1700,12 @@ private:
else
d = internal::StrtodNormalPrecision(d, p);
if (d == std::numeric_limits<double>::infinity()) {
// Overflow
// TODO: internal::StrtodX should report overflow (or underflow)
RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, startOffset);
}
cont = handler.Double(minus ? -d : d);
}
else if (useNanOrInf) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment