From c1441ef5e04c6b2e8db15cf043fd43eab2910ca2 Mon Sep 17 00:00:00 2001 From: datadiode Date: Thu, 15 Jan 2015 08:32:13 +0100 Subject: [PATCH 1/2] stricter float parsing fixes `test/jsonchecker/fail31.json` (issue #113) --- src/lib_json/json_reader.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index c5111f8..dfae3fb 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -381,11 +381,24 @@ bool Reader::readCppStyleComment() { } void Reader::readNumber() { - while (current_ != end_) { - if (!(*current_ >= '0' && *current_ <= '9') && - !in(*current_, '.', 'e', 'E', '+', '-')) - break; - ++current_; + const char *p = current_; + char c = '0'; // stopgap for already consumed character + // integral part + while (c >= '0' && c <= '9') + c = (current_ = p) < end_ ? *p++ : 0; + // fractional part + if (c == '.') { + c = (current_ = p) < end_ ? *p++ : 0; + while (c >= '0' && c <= '9') + c = (current_ = p) < end_ ? *p++ : 0; + } + // exponential part + if (c == 'e' || c == 'E') { + c = (current_ = p) < end_ ? *p++ : 0; + if (c == '+' || c == '-') + c = (current_ = p) < end_ ? *p++ : 0; + while (c >= '0' && c <= '9') + c = (current_ = p) < end_ ? *p++ : 0; } } From 4997dfb8afe181b043fc22e2663f9c9702d4255c Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Fri, 16 Jan 2015 15:09:54 -0600 Subject: [PATCH 2/2] 1.1.1 <- 1.1.0 slight change to fail on a bad float --- .gitignore | 2 +- include/json/version.h | 4 ++-- version | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 60c4a0b..88a0b0d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ /libs/ /doc/doxyfile /dist/ -/include/json/version.h +#/include/json/version.h diff --git a/include/json/version.h b/include/json/version.h index 58fca8a..baf5daa 100644 --- a/include/json/version.h +++ b/include/json/version.h @@ -4,10 +4,10 @@ #ifndef JSON_VERSION_H_INCLUDED # define JSON_VERSION_H_INCLUDED -# define JSONCPP_VERSION_STRING "1.1.0" +# define JSONCPP_VERSION_STRING "1.1.1" # define JSONCPP_VERSION_MAJOR 1 # define JSONCPP_VERSION_MINOR 1 -# define JSONCPP_VERSION_PATCH 0 +# define JSONCPP_VERSION_PATCH 1 # define JSONCPP_VERSION_QUALIFIER # define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8)) diff --git a/version b/version index 6314dac..cd075f2 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.1.0 \ No newline at end of file +1.1.1 \ No newline at end of file