Skip to content

Commit 6dfbb72

Browse files
committed
Java: Add constant array lengths to ConstantIntegerExpr.
1 parent 85cca69 commit 6dfbb72

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

java/ql/src/semmle/code/java/dataflow/RangeUtils.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ private predicate constantIntegerExpr(Expr e, int val) {
1515
src = v.getDefiningExpr().(VariableAssign).getSource() and
1616
constantIntegerExpr(src, val)
1717
)
18+
or
19+
exists(SsaExplicitUpdate v, FieldRead arrlen |
20+
e = arrlen and
21+
arrlen.getField() instanceof ArrayLengthField and
22+
arrlen.getQualifier() = v.getAUse() and
23+
v.getDefiningExpr().(VariableAssign).getSource().(ArrayCreationExpr).getFirstDimensionSize() = val
24+
)
1825
}
1926

2027
/** An expression that always has the same integer value. */

0 commit comments

Comments
 (0)