Skip to content

Commit 44b30b7

Browse files
committed
C#: Fix Modifiable::isUnsafe to handle declarations extracted from assemblies
1 parent 87ee784 commit 44b30b7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

csharp/ql/src/semmle/code/csharp/Member.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@ class Modifiable extends Declaration, @modifiable {
8686
predicate isConst() { this.hasModifier("const") }
8787

8888
/** Holds if this declaration is `unsafe`. */
89-
predicate isUnsafe() { this.hasModifier("unsafe") }
89+
predicate isUnsafe() {
90+
this.hasModifier("unsafe") or
91+
this.(Parameterizable).getAParameter().getType() instanceof PointerType or
92+
this.(Property).getType() instanceof PointerType or
93+
this.(Callable).getReturnType() instanceof PointerType
94+
}
9095

9196
/** Holds if this declaration is `async`. */
9297
predicate isAsync() { this.hasModifier("async") }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import csharp
22

3-
select any(Modifiable m | m.isUnsafe())
3+
select any(Modifiable m | m.isUnsafe() and m.fromSource())

0 commit comments

Comments
 (0)