Skip to content

Java: Fix accidental cartesian product. #15045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import semmle.code.java.Maps
private import semmle.code.java.dataflow.SSA
private import DataFlowUtil

private class ArrayType extends RefType {
ArrayType() { this.getSourceDeclaration().getASourceSupertype*() instanceof Array }
}

private class EntryType extends RefType {
EntryType() {
this.getSourceDeclaration().getASourceSupertype*().hasQualifiedName("java.util", "Map$Entry")
Expand Down Expand Up @@ -455,7 +451,7 @@ predicate arrayStoreStep(Node node1, Node node2) {
arr = node2.(PostUpdateNode).getPreUpdateNode().asExpr() and
call.getArgument(1) = node1.asExpr() and
call.getQualifier() = arr and
arr.getType() instanceof ArrayType and
arr.getType() instanceof Array and
call.getCallee().getName() = "set"
)
}
Expand Down Expand Up @@ -485,7 +481,7 @@ predicate arrayReadStep(Node node1, Node node2, Type elemType) {
exists(Expr arr, Call call |
arr = node1.asExpr() and
call = node2.asExpr() and
arr.getType() instanceof ArrayType and
arr.getType().(Array).getComponentType() = elemType and
call.getCallee().getName() = "get" and
call.getQualifier() = arr
)
Expand Down