C++: Only recognize signed integers as sinks in 'cpp/uncontrolled-arithmetic' in the case of overflow.

This commit is contained in:
Mathias Vorreiter Pedersen
2021-12-20 14:02:44 +01:00
parent b49ca6a24c
commit 95fa93b274

View File

@@ -82,8 +82,11 @@ predicate missingGuard(VariableAccess va, string effect) {
op.getUnspecifiedType().(IntegralType).isUnsigned() and
not op instanceof MulExpr
or
// overflow
missingGuardAgainstOverflow(op, va) and effect = "overflow"
// overflow - only report signed integer overflow since unsigned overflow
// is well-defined.
op.getUnspecifiedType().(IntegralType).isSigned() and
missingGuardAgainstOverflow(op, va) and
effect = "overflow"
)
}