Skip to content

Commit 67e7b8f

Browse files
committed
C#: If a type (or any child of a type) is a pointer like type then it is unsafe.
1 parent a4c0a03 commit 67e7b8f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,21 @@ class Modifiable extends Declaration, @modifiable {
9898

9999
/** Holds if this declaration is `unsafe`. */
100100
predicate isUnsafe() {
101-
this.hasModifier("unsafe") or
102-
this.(Parameterizable).getAParameter().getType() instanceof PointerType or
103-
this.(Property).getType() instanceof PointerType or
104-
this.(Callable).getReturnType() instanceof PointerType
101+
this.hasModifier("unsafe")
102+
or
103+
exists(Type t, Type child |
104+
t = this.(Parameterizable).getAParameter().getType() or
105+
t = this.(Property).getType() or
106+
t = this.(Callable).getReturnType() or
107+
t = this.(DelegateType).getReturnType()
108+
|
109+
child = t.getAChild*() and
110+
(
111+
child instanceof PointerType
112+
or
113+
child instanceof FunctionPointerType
114+
)
115+
)
105116
}
106117

107118
/** Holds if this declaration is `async`. */

0 commit comments

Comments
 (0)