未验证 提交 933db22e 编写于 作者: O openharmony_ci 提交者: Gitee

!17 Fix the parsing error when JSONCPP parses the value of 5E-324 with libc++ on Release

Merge pull request !17 from hufeng/cherry-pick-1647775771
...@@ -1666,6 +1666,12 @@ bool OurReader::decodeDouble(Token& token, Value& decoded) { ...@@ -1666,6 +1666,12 @@ bool OurReader::decodeDouble(Token& token, Value& decoded) {
const String buffer(token.start_, token.end_); const String buffer(token.start_, token.end_);
IStringStream is(buffer); IStringStream is(buffer);
if (!(is >> value)) { if (!(is >> value)) {
// the value could be lower than numeric_limits<double>::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<double>::min()) || (value < 0 && value > -std::numeric_limits<double>::min())) {
decoded = value;
return true;
}
return addError( return addError(
"'" + String(token.start_, token.end_) + "' is not a number.", token); "'" + String(token.start_, token.end_) + "' is not a number.", token);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册