mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-13 10:22:55 +01:00
reader: 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.
This commit is contained in:
parent
009a3ad24c
commit
056850c44b
@ -1564,7 +1564,7 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) {
|
|||||||
// TODO: Help the compiler do the div and mod at compile time or get rid of
|
// TODO: Help the compiler do the div and mod at compile time or get rid of
|
||||||
// them.
|
// them.
|
||||||
Value::LargestUInt maxIntegerValue =
|
Value::LargestUInt maxIntegerValue =
|
||||||
isNegative ? Value::LargestUInt(-Value::minLargestInt)
|
isNegative ? Value::LargestUInt(Value::minLargestInt)
|
||||||
: Value::maxLargestUInt;
|
: Value::maxLargestUInt;
|
||||||
Value::LargestUInt threshold = maxIntegerValue / 10;
|
Value::LargestUInt threshold = maxIntegerValue / 10;
|
||||||
Value::LargestUInt value = 0;
|
Value::LargestUInt value = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user