Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions include/rapidjson/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -1497,27 +1497,29 @@ class GenericReader {

if (minus)
while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
i = i * 10 + static_cast<unsigned>(s.TakePush() - '0');
significandDigit++;

if (RAPIDJSON_UNLIKELY(i >= 214748364)) { // 2^31 = 2147483648
if (RAPIDJSON_LIKELY(i != 214748364 || s.Peek() > '8')) {
i64 = i;
use64bit = true;
break;
}
}
i = i * 10 + static_cast<unsigned>(s.TakePush() - '0');
significandDigit++;
}
else
while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
i = i * 10 + static_cast<unsigned>(s.TakePush() - '0');
significandDigit++;

if (RAPIDJSON_UNLIKELY(i >= 429496729)) { // 2^32 - 1 = 4294967295
if (RAPIDJSON_LIKELY(i != 429496729 || s.Peek() > '5')) {
i64 = i;
use64bit = true;
break;
}
}
i = i * 10 + static_cast<unsigned>(s.TakePush() - '0');
significandDigit++;
}
}
// Parse NaN or Infinity here
Expand Down