Skip to content

Commit cd85f60

Browse files
committed
bail on overflow
1 parent e8ebeee commit cd85f60

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎lib/valueflow.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3752,8 +3752,13 @@ static void valueFlowSymbolicOperators(const SymbolDatabase& symboldatabase, con
37523752
continue;
37533753
if (!ids.insert(value.tokvalue->exprId()).second)
37543754
continue;
3755+
const bool add = tok->str() == "+";
3756+
if (add && MathLib::additionWouldOverflow(value.intvalue, constant->intvalue))
3757+
continue;
3758+
if (!add && MathLib::subtractionWouldOverflow(value.intvalue, constant->intvalue))
3759+
continue;
37553760
ValueFlow::Value newValue(value);
3756-
newValue.intvalue += tok->str() == "-" ? -constant->intvalue : constant->intvalue;
3761+
newValue.intvalue = add ? newValue.intvalue + constant->intvalue : newValue.intvalue - constant->intvalue;
37573762
setTokenValue(tok, std::move(newValue), settings);
37583763
}
37593764
}

0 commit comments

Comments
 (0)