Skip to content

Commit 344f7bc

Browse files
authored
Merge pull request #7187 from aschackmull/java/dont-clear-in-summary-store
Java: Don't clear content in store steps in summaries.
2 parents 47fd64f + fc43220 commit 344f7bc

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,11 @@ predicate readStep(Node node1, Content f, Node node2) {
150150
* in `x.f = newValue`.
151151
*/
152152
predicate clearsContent(Node n, Content c) {
153-
c instanceof FieldContent and
154-
n = any(PostUpdateNode pun | storeStep(_, c, pun)).getPreUpdateNode()
153+
exists(FieldAccess fa |
154+
instanceFieldAssign(_, fa) and
155+
n = getFieldQualifier(fa) and
156+
c.(FieldContent).getField() = fa.getField()
157+
)
155158
or
156159
FlowSummaryImpl::Private::Steps::summaryClearsContent(n, c)
157160
}

java/ql/test/library-tests/dataflow/callback-dispatch/A.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ void foo3() {
174174
a1.field1 = source(20);
175175
A a2 = new A();
176176
applyConsumer1Field1Field2(a1, a2, p -> {
177-
sink(p); // MISSING FLOW
177+
sink(p); // $ flow=20
178178
});
179179
wrapSinkToAvoidFieldSsa(a1);
180180
sink(a2.field2);

0 commit comments

Comments
 (0)