diff options
author | Adam Cozzette <acozzette@google.com> | 2016-11-17 16:48:38 -0800 |
---|---|---|
committer | Adam Cozzette <acozzette@google.com> | 2016-11-17 16:59:59 -0800 |
commit | 5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74 (patch) | |
tree | 0276f81f8848a05d84cd7e287b43d665e30f04e3 /src/google/protobuf/util/internal/json_stream_parser.cc | |
parent | e28286fa05d8327fd6c5aa70cfb3be558f0932b8 (diff) | |
download | protobuf-5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74.tar.gz protobuf-5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74.tar.bz2 protobuf-5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74.zip |
Integrated internal changes from Google
Diffstat (limited to 'src/google/protobuf/util/internal/json_stream_parser.cc')
-rw-r--r-- | src/google/protobuf/util/internal/json_stream_parser.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc index a8d48eff..2af4ad90 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.cc +++ b/src/google/protobuf/util/internal/json_stream_parser.cc @@ -45,6 +45,8 @@ #include <google/protobuf/util/internal/object_writer.h> #include <google/protobuf/util/internal/json_escaping.h> #include <google/protobuf/stubs/strutil.h> +#include <google/protobuf/stubs/mathlimits.h> + namespace google { namespace protobuf { @@ -108,7 +110,8 @@ JsonStreamParser::JsonStreamParser(ObjectWriter* ow) string_open_(0), chunk_storage_(), coerce_to_utf8_(false), - allow_empty_null_(false) { + allow_empty_null_(false), + loose_float_number_conversion_(false) { // Initialize the stack with a single value to be parsed. stack_.push(VALUE); } @@ -532,6 +535,10 @@ util::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) { if (!safe_strtod(number, &result->double_val)) { return ReportFailure("Unable to parse number."); } + if (!loose_float_number_conversion_ && + !MathLimits<double>::IsFinite(result->double_val)) { + return ReportFailure("Number exceeds the range of double."); + } result->type = NumberResult::DOUBLE; p_.remove_prefix(index); return util::Status::OK; |