Skip to content

Commit 9191acc

Browse files
committed
C#: Prevent flow out of non ref fields in ref structs used as arguments.
1 parent 4a89cbe commit 9191acc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,6 +2017,14 @@ predicate clearsContent(Node n, ContentSet c) {
20172017
f = oi.getAMemberInitializer().getInitializedMember() and
20182018
c = f.getContent()
20192019
)
2020+
or
2021+
exists(Argument a, Struct s, Field f |
2022+
a = n.(PostUpdateNode).getPreUpdateNode().asExpr() and
2023+
a.getType() = s and
2024+
f = s.getAField() and
2025+
c.(FieldContent).getField() = f.getUnboundDeclaration() and
2026+
not f.isRef()
2027+
)
20202028
}
20212029

20222030
/**

0 commit comments

Comments
 (0)