summaryrefslogtreecommitdiff
path: root/Utilities/cmjsoncpp
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-12-11 12:44:57 -0500
committerBrad King <brad.king@kitware.com>2018-12-11 12:50:21 -0500
commit5751a09092a35554ebdd75ea0aa05c63ec414734 (patch)
tree30281f8ae8d5b3460791c043c131e6c03e024d60 /Utilities/cmjsoncpp
parentd8c6427fa158a96a2e41f07d60c924cee94e413b (diff)
downloadcmake-5751a09092a35554ebdd75ea0aa05c63ec414734.tar.gz
jsoncpp: fix signed overflow when parsing negative value
Clang's ubsan (-fsanitize=undefined) reports: runtime error: negation of -9223372036854775808 cannot be represented in type 'Json::Value::LargestInt' (aka 'long'); cast to an unsigned type to negate this value to itself Follow its advice and update the code to remove the explicit negation.
Diffstat (limited to 'Utilities/cmjsoncpp')
-rw-r--r--Utilities/cmjsoncpp/src/lib_json/json_reader.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp b/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp
index 0249cc9f13..6eeba0e65e 100644
--- a/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp
+++ b/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp
@@ -1581,7 +1581,7 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) {
++current;
// TODO: Help the compiler do the div and mod at compile time or get rid of them.
Value::LargestUInt maxIntegerValue =
- isNegative ? Value::LargestUInt(-Value::minLargestInt)
+ isNegative ? Value::LargestUInt(Value::minLargestInt)
: Value::maxLargestUInt;
Value::LargestUInt threshold = maxIntegerValue / 10;
Value::LargestUInt value = 0;