Fix number reading in the presence of Infinity: Only check for infinity if we have...
authordrgler <daniel.kruegler@gmail.com>
Sat, 5 Sep 2015 12:49:33 +0000 (14:49 +0200)
committerdrgler <daniel.kruegler@gmail.com>
Sat, 5 Sep 2015 12:49:33 +0000 (14:49 +0200)
src/lib_json/json_reader.cpp

index a8b1fe2..5b2f7b6 100644 (file)
@@ -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;
   }