Skip to content

Commit 68509e6

Browse files
committed
Fix number reading in the presence of Infinity: Only check for infinity if we have a leading sign character.
1 parent 4cea1f6 commit 68509e6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/lib_json/json_reader.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ class OurReader {
988988
bool readCppStyleComment();
989989
bool readString();
990990
bool readStringSingleQuote();
991-
bool readNumber();
991+
bool readNumber(bool checkInf);
992992
bool readValue();
993993
bool readObject(Token& token);
994994
bool readArray(Token& token);
@@ -1246,8 +1246,11 @@ bool OurReader::readToken(Token& token) {
12461246
case '7':
12471247
case '8':
12481248
case '9':
1249+
token.type_ = tokenNumber;
1250+
readNumber(false);
1251+
break;
12491252
case '-':
1250-
if (readNumber()) {
1253+
if (readNumber(true)) {
12511254
token.type_ = tokenNumber;
12521255
} else {
12531256
token.type_ = tokenNegInf;
@@ -1382,9 +1385,9 @@ bool OurReader::readCppStyleComment() {
13821385
return true;
13831386
}
13841387

1385-
bool OurReader::readNumber() {
1388+
bool OurReader::readNumber(bool checkInf) {
13861389
const char *p = current_;
1387-
if (p != end_ && *p == 'I') {
1390+
if (checkInf && p != end_ && *p == 'I') {
13881391
current_ = ++p;
13891392
return false;
13901393
}

0 commit comments

Comments
 (0)