Skip to content

Commit c68d0bc

Browse files
authored
Merge pull request github#14099 from hvitved/csharp/transitive-capture-call-unique
C#: Do not embed target callable in `TransitiveCapturedCall`
2 parents ded4901 + 29982fe commit c68d0bc

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ private module Cached {
109109
TExplicitDelegateLikeCall(ControlFlow::Nodes::ElementNode cfn, DelegateLikeCall dc) {
110110
cfn.getAstNode() = dc
111111
} or
112-
TTransitiveCapturedCall(ControlFlow::Nodes::ElementNode cfn, Callable target) {
113-
transitiveCapturedCallTarget(cfn, target)
112+
TTransitiveCapturedCall(ControlFlow::Nodes::ElementNode cfn) {
113+
transitiveCapturedCallTarget(cfn, _)
114114
} or
115115
TCilCall(CIL::Call call) {
116116
// No need to include calls that are compiled from source
@@ -389,11 +389,12 @@ class ExplicitDelegateLikeDataFlowCall extends DelegateDataFlowCall, TExplicitDe
389389
*/
390390
class TransitiveCapturedDataFlowCall extends DataFlowCall, TTransitiveCapturedCall {
391391
private ControlFlow::Nodes::ElementNode cfn;
392-
private Callable target;
393392

394-
TransitiveCapturedDataFlowCall() { this = TTransitiveCapturedCall(cfn, target) }
393+
TransitiveCapturedDataFlowCall() { this = TTransitiveCapturedCall(cfn) }
395394

396-
override DataFlowCallable getARuntimeTarget() { result.asCallable() = target }
395+
override DataFlowCallable getARuntimeTarget() {
396+
transitiveCapturedCallTarget(cfn, result.asCallable())
397+
}
397398

398399
override ControlFlow::Nodes::ElementNode getControlFlowNode() { result = cfn }
399400

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ private module OutNodes {
15641564
additionalCalls = false and call = csharpCall(_, cfn)
15651565
or
15661566
additionalCalls = true and
1567-
call = TTransitiveCapturedCall(cfn, n.getEnclosingCallable())
1567+
call = TTransitiveCapturedCall(cfn)
15681568
)
15691569
}
15701570

0 commit comments

Comments
 (0)