Skip to content

Commit 1629b49

Browse files
committed
Rust: SSA: restrict mutablyBorrowed to variables with a 'mut' modifier
1 parent 45db4ae commit 1629b49

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

rust/ql/lib/codeql/rust/dataflow/internal/SsaImpl.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ predicate capturedCallWrite(Expr call, BasicBlock bb, int i, Variable v) {
212212
/** Holds if `v` may be mutably borrowed in `e`. */
213213
private predicate mutablyBorrows(Expr e, Variable v) {
214214
e = any(MethodCallExpr mc).getReceiver() and
215-
e.(VariableAccess).getVariable() = v
215+
e.(VariableAccess).getVariable() = v and
216+
v.isMutable()
216217
or
217218
exists(RefExpr re | re = e and re.isMut() and re.getExpr().(VariableAccess).getVariable() = v)
218219
}

0 commit comments

Comments
 (0)