RapidJSON: fix bug when parsing NaN, Inf with fraction or exponent parts

Merge Tencent/rapidjson@7c73dd7de7
This commit is contained in:
Kawe Mazidjatari 2024-09-16 17:48:25 +02:00
parent a6d4a53021
commit 0b568488e3

View File

@ -1584,7 +1584,7 @@ private:
// Parse frac = decimal-point 1*DIGIT
int expFrac = 0;
size_t decimalPosition;
if (Consume(s, '.')) {
if (!useNanOrInf && Consume(s, '.')) {
decimalPosition = s.Length();
if (RAPIDJSON_UNLIKELY(!(s.Peek() >= '0' && s.Peek() <= '9')))
@ -1631,7 +1631,7 @@ private:
// Parse exp = e [ minus / plus ] 1*DIGIT
int exp = 0;
if (Consume(s, 'e') || Consume(s, 'E')) {
if (!useNanOrInf && (Consume(s, 'e') || Consume(s, 'E'))) {
if (!useDouble) {
d = static_cast<double>(use64bit ? i64 : i);
useDouble = true;