From 6af3cf5cff6dbe83936f8cffd0d8fe3bf483f962 Mon Sep 17 00:00:00 2001 From: hufeng Date: Sun, 20 Mar 2022 19:26:24 +0800 Subject: [PATCH] fixed 539859d from https://gitee.com/hufeng20/third_party_jsoncpp/pulls/16 Fix the parsing error when JSONCPP parses the value of 5E-324 with libc++ Signed-off-by: hufeng Change-Id: I1aaef25e133af8a1177713280c2f6657db182e81 --- src/lib_json/json_reader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index f233abb..8f4c544 100755 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -1666,6 +1666,12 @@ bool OurReader::decodeDouble(Token& token, Value& decoded) { const String buffer(token.start_, token.end_); IStringStream is(buffer); if (!(is >> value)) { + // the value could be lower than numeric_limits::min(), in this situtation we should return the value with the gurantee + // of conversion which has been performed and no occurances of range error. + if ((value > 0 && value < std::numeric_limits::min()) || (value < 0 && value > -std::numeric_limits::min())) { + decoded = value; + return true; + } return addError( "'" + String(token.start_, token.end_) + "' is not a number.", token); } -- GitLab