Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Java: Improve join by preventing ssa use-pair join.
  • Loading branch information
aschackmull committed Jul 18, 2025
commit ca8fe033d756104a47481cb0ba250c8cd6d35da9
17 changes: 11 additions & 6 deletions java/ql/src/Likely Bugs/Collections/ArrayIndexOutOfBounds.ql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ import semmle.code.java.dataflow.SSA
import semmle.code.java.dataflow.RangeUtils
import semmle.code.java.dataflow.RangeAnalysis

pragma[nomagic]
predicate ssaArrayLengthBound(SsaVariable arr, Bound b) {
exists(FieldAccess len |
len.getField() instanceof ArrayLengthField and
len.getQualifier() = arr.getAUse() and
b.getExpr() = len
)
}

/**
* Holds if the index expression of `aa` is less than or equal to the array length plus `k`.
*/
Expand All @@ -27,12 +36,8 @@ predicate boundedArrayAccess(ArrayAccess aa, int k) {
aa.getArray() = arr.getAUse() and
bounded(index, b, delta, true, _)
|
exists(FieldAccess len |
len.getField() instanceof ArrayLengthField and
len.getQualifier() = arr.getAUse() and
b.getExpr() = len and
k = delta
)
ssaArrayLengthBound(arr, b) and
k = delta
or
exists(ArrayCreationExpr arraycreation | arraycreation = getArrayDef(arr) |
k = delta and
Expand Down