Skip to content

Commit e4bd198

Browse files
committed
C#: Search from delegate creation in delegateCallSource()
1 parent 18c3bfe commit e4bd198

File tree

1 file changed

+9
-11
lines changed
  • csharp/ql/src/semmle/code/csharp/dataflow

1 file changed

+9
-11
lines changed

csharp/ql/src/semmle/code/csharp/dataflow/SSA.qll

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,29 +1076,27 @@ module Ssa {
10761076
)
10771077
}
10781078

1079-
private predicate reachableFromDelegateCreation(Expr e) {
1080-
delegateCreation(e, _, _)
1079+
private predicate reachesDelegateCall(Expr e) {
1080+
delegateCall(_, e)
10811081
or
1082-
exists(Expr mid | reachableFromDelegateCreation(mid) | delegateFlowStep(mid, e))
1082+
exists(Expr mid | reachesDelegateCall(mid) | delegateFlowStep(e, mid))
10831083
}
10841084

10851085
pragma[noinline]
1086-
private predicate delegateFlowStepReachable(Expr pred, Expr succ) {
1086+
private predicate delegateFlowStepReaches(Expr pred, Expr succ) {
10871087
delegateFlowStep(pred, succ) and
1088-
reachableFromDelegateCreation(pred)
1088+
reachesDelegateCall(succ)
10891089
}
10901090

1091-
private Expr delegateCallSource(Call c) {
1092-
// Base case
1093-
delegateCall(c, result)
1091+
private Expr delegateCallSource(Callable c) {
1092+
delegateCreation(result, c, _)
10941093
or
1095-
// Recursive case
1096-
delegateFlowStepReachable(result, delegateCallSource(c))
1094+
delegateFlowStepReaches(delegateCallSource(c), result)
10971095
}
10981096

10991097
/** Gets a run-time target for the delegate call `c`. */
11001098
Callable getARuntimeDelegateTarget(Call c) {
1101-
delegateCreation(delegateCallSource(c), result, _)
1099+
delegateCall(c, delegateCallSource(result))
11021100
}
11031101
}
11041102

0 commit comments

Comments
 (0)