@@ -4,6 +4,10 @@ import semmle.code.java.Maps
44private import semmle.code.java.dataflow.SSA
55private import DataFlowUtil
66
7+ private class ArrayType extends RefType {
8+ ArrayType ( ) { this .getSourceDeclaration ( ) .getASourceSupertype * ( ) instanceof Array }
9+ }
10+
711private class EntryType extends RefType {
812 EntryType ( ) {
913 this .getSourceDeclaration ( ) .getASourceSupertype * ( ) .hasQualifiedName ( "java.util" , "Map$Entry" )
@@ -446,6 +450,14 @@ predicate arrayStoreStep(Node node1, Node node2) {
446450 exists ( Assignment assign | assign .getSource ( ) = node1 .asExpr ( ) |
447451 node2 .( PostUpdateNode ) .getPreUpdateNode ( ) .asExpr ( ) = assign .getDest ( ) .( ArrayAccess ) .getArray ( )
448452 )
453+ or
454+ exists ( Expr arr , Call call |
455+ arr = node2 .asExpr ( ) and
456+ call .getArgument ( 1 ) = node1 .asExpr ( ) and
457+ call .getQualifier ( ) = arr and
458+ arr .getType ( ) instanceof ArrayType and
459+ call .getCallee ( ) .getName ( ) = "set"
460+ )
449461}
450462
451463private predicate enhancedForStmtStep ( Node node1 , Node node2 , Type containerType ) {
@@ -470,6 +482,14 @@ predicate arrayReadStep(Node node1, Node node2, Type elemType) {
470482 node2 .asExpr ( ) = aa
471483 )
472484 or
485+ exists ( Expr arr , Call call |
486+ arr = node1 .asExpr ( ) and
487+ call = node2 .asExpr ( ) and
488+ arr .getType ( ) instanceof ArrayType and
489+ call .getCallee ( ) .getName ( ) = "get" and
490+ call .getQualifier ( ) = arr
491+ )
492+ or
473493 exists ( Array arr |
474494 enhancedForStmtStep ( node1 , node2 , arr ) and
475495 arr .getComponentType ( ) = elemType
0 commit comments