Skip to content

Commit 0618568

Browse files
authored
Merge pull request #15045 from aschackmull/java/fix-cp
Java: Fix accidental cartesian product.
2 parents 1ea2f89 + 7ee3068 commit 0618568

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

java/ql/lib/semmle/code/java/dataflow/internal/ContainerFlow.qll

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import semmle.code.java.Maps
44
private import semmle.code.java.dataflow.SSA
55
private import DataFlowUtil
66

7-
private class ArrayType extends RefType {
8-
ArrayType() { this.getSourceDeclaration().getASourceSupertype*() instanceof Array }
9-
}
10-
117
private class EntryType extends RefType {
128
EntryType() {
139
this.getSourceDeclaration().getASourceSupertype*().hasQualifiedName("java.util", "Map$Entry")
@@ -455,7 +451,7 @@ predicate arrayStoreStep(Node node1, Node node2) {
455451
arr = node2.(PostUpdateNode).getPreUpdateNode().asExpr() and
456452
call.getArgument(1) = node1.asExpr() and
457453
call.getQualifier() = arr and
458-
arr.getType() instanceof ArrayType and
454+
arr.getType() instanceof Array and
459455
call.getCallee().getName() = "set"
460456
)
461457
}
@@ -485,7 +481,7 @@ predicate arrayReadStep(Node node1, Node node2, Type elemType) {
485481
exists(Expr arr, Call call |
486482
arr = node1.asExpr() and
487483
call = node2.asExpr() and
488-
arr.getType() instanceof ArrayType and
484+
arr.getType().(Array).getComponentType() = elemType and
489485
call.getCallee().getName() = "get" and
490486
call.getQualifier() = arr
491487
)

0 commit comments

Comments
 (0)