Skip to content

Commit 914c711

Browse files
committed
C#: Fix broken viableImplInCallContext implementation
1 parent f4b82cb commit 914c711

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,19 @@ private module DispatchImpl {
175175
* restricted to those `call`s for which a context might make a difference.
176176
*/
177177
DataFlowCallable viableImplInCallContext(NonDelegateDataFlowCall call, DataFlowCall ctx) {
178-
result.getUnderlyingCallable() =
179-
call.getDispatchCall()
180-
.getADynamicTargetInCallContext(ctx.(NonDelegateDataFlowCall).getDispatchCall())
181-
.getUnboundDeclaration()
178+
exists(DispatchCall dc | dc = call.getDispatchCall() |
179+
result.getUnderlyingCallable() =
180+
getCallableForDataFlow(dc.getADynamicTargetInCallContext(ctx.(NonDelegateDataFlowCall)
181+
.getDispatchCall()).getUnboundDeclaration())
182+
or
183+
exists(Callable c, DataFlowCallable encl |
184+
result.asSummarizedCallable() = c and
185+
mayBenefitFromCallContext(call, encl) and
186+
encl = ctx.getARuntimeTarget() and
187+
c = dc.getAStaticTarget().getUnboundDeclaration() and
188+
not c instanceof RuntimeCallable
189+
)
190+
)
182191
}
183192
}
184193

0 commit comments

Comments
 (0)