From 68509e61610d101caee74f479055a1e641d36457 Mon Sep 17 00:00:00 2001 From: drgler Date: Sat, 5 Sep 2015 14:49:33 +0200 Subject: [PATCH] Fix number reading in the presence of Infinity: Only check for infinity if we have a leading sign character. --- src/lib_json/json_reader.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index a8b1fe2..5b2f7b6 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -988,7 +988,7 @@ private: bool readCppStyleComment(); bool readString(); bool readStringSingleQuote(); - bool readNumber(); + bool readNumber(bool checkInf); bool readValue(); bool readObject(Token& token); bool readArray(Token& token); @@ -1246,8 +1246,11 @@ bool OurReader::readToken(Token& token) { case '7': case '8': case '9': + token.type_ = tokenNumber; + readNumber(false); + break; case '-': - if (readNumber()) { + if (readNumber(true)) { token.type_ = tokenNumber; } else { token.type_ = tokenNegInf; @@ -1382,9 +1385,9 @@ bool OurReader::readCppStyleComment() { return true; } -bool OurReader::readNumber() { +bool OurReader::readNumber(bool checkInf) { const char *p = current_; - if (p != end_ && *p == 'I') { + if (checkInf && p != end_ && *p == 'I') { current_ = ++p; return false; }