mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Merge pull request #2305 from aschackmull/java/overflowcheck-conditionalexpr
Java: Add ConditionalExpr to overflow candidate pattern.
This commit is contained in:
@@ -132,6 +132,11 @@ Expr overFlowCand() {
|
||||
result.(AssignExpr).getRhs() = overFlowCand()
|
||||
or
|
||||
result.(LocalVariableDeclExpr).getInit() = overFlowCand()
|
||||
or
|
||||
exists(ConditionalExpr c | c = result |
|
||||
c.getTrueExpr() = overFlowCand() and
|
||||
c.getFalseExpr() = overFlowCand()
|
||||
)
|
||||
}
|
||||
|
||||
predicate positiveOrNegative(Expr e) { positive(e) or negative(e) }
|
||||
|
||||
@@ -121,6 +121,11 @@ public class A {
|
||||
}
|
||||
}
|
||||
|
||||
void overflowTests2(int[] a, boolean b) {
|
||||
int newlen = b ? (a.length + 1) << 1 : (a.length >> 1) + a.length;
|
||||
if (newlen < 0) overflow();
|
||||
}
|
||||
|
||||
static final long VAL = 100L;
|
||||
|
||||
long overflowAwareIncrease(long x) {
|
||||
|
||||
Reference in New Issue
Block a user