Skip to content

Commit 6fcd358

Browse files
committed
Fix pointer content store step for write to field of pointer dereference
1 parent 2ffb638 commit 6fcd358

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

go/ql/lib/semmle/go/dataflow/internal/DataFlowPrivate.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,17 @@ predicate jumpStep(Node n1, Node n2) {
164164
*/
165165
predicate storeStep(Node node1, ContentSet cs, Node node2) {
166166
exists(Content c | cs.asOneContent() = c |
167-
// a write `(*p).f = rhs` is modeled as two store steps: `rhs` is flows into field `f` of `(*p)`,
168-
// which in turn flows into the pointer content of `p`
167+
// a write `(*p).f = rhs` is modeled as two store steps: `rhs` is flows into field `f` of the
168+
// post-update node of `(*p)`, which in turn flows into the pointer content of the post-update
169+
// node of `p`
169170
exists(Write w, Field f, DataFlow::Node base, DataFlow::Node rhs | w.writesField(base, f, rhs) |
170171
node1 = rhs and
171172
node2 = base and
172173
c = any(DataFlow::FieldContent fc | fc.getField() = f)
173174
or
174175
node1 = base and
175-
node2.(PostUpdateNode).getPreUpdateNode() = node1.(PointerDereferenceNode).getOperand() and
176+
node2.(PostUpdateNode).getPreUpdateNode() =
177+
node1.(PostUpdateNode).getPreUpdateNode().(PointerDereferenceNode).getOperand() and
176178
c = any(DataFlow::PointerContent pc | pc.getPointerType() = node2.getType())
177179
)
178180
or

0 commit comments

Comments
 (0)