mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
Java: Exclude loop conditions from overflow check heuristic.
This commit is contained in:
@@ -168,10 +168,14 @@ Expr increaseOrDecreaseOfVar(SsaVariable v) {
|
||||
}
|
||||
|
||||
predicate overFlowTest(ComparisonExpr comp) {
|
||||
exists(SsaVariable v | comp.hasOperands(increaseOrDecreaseOfVar(v), v.getAUse()))
|
||||
or
|
||||
comp.getLesserOperand() = overFlowCand() and
|
||||
comp.getGreaterOperand().(IntegerLiteral).getIntValue() = 0
|
||||
(
|
||||
exists(SsaVariable v | comp.hasOperands(increaseOrDecreaseOfVar(v), v.getAUse()))
|
||||
or
|
||||
comp.getLesserOperand() = overFlowCand() and
|
||||
comp.getGreaterOperand().(IntegerLiteral).getIntValue() = 0
|
||||
) and
|
||||
// exclude loop conditions as they are unlikely to be overflow tests
|
||||
not comp.getEnclosingStmt() instanceof LoopStmt
|
||||
}
|
||||
|
||||
predicate concurrentModificationTest(BinaryExpr test) {
|
||||
|
||||
Reference in New Issue
Block a user