diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowDispatch.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowDispatch.qll index 31956756c60..c7d34a38979 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowDispatch.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowDispatch.qll @@ -27,6 +27,12 @@ newtype TReturnKind = private predicate hasMultipleSourceLocations(Callable c) { strictcount(getASourceLocation(c)) > 1 } +private predicate objectInitEntry(ObjectInitMethod m, ControlFlowElement first) { + exists(ControlFlow::Nodes::EntryNode en | + en.getCallable() = m and first.getControlFlowNode() = en.getASuccessor() + ) +} + private module NearestBodyLocationInput implements NearestLocationInputSig { class C = ControlFlowElement; @@ -34,7 +40,7 @@ private module NearestBodyLocationInput implements NearestLocationInputSig { exists(Callable c | hasMultipleSourceLocations(c) and l1 = getASourceLocation(c) and - body = c.getBody() and + (body = c.getBody() or objectInitEntry(c, body)) and l2 = body.getLocation() ) } @@ -207,7 +213,9 @@ class DataFlowCallable extends TDataFlowCallable { private ControlFlow::Nodes::ElementNode getAMultiBodyEntryNode(ControlFlow::BasicBlock bb, int i) { this.isMultiBodied() and exists(ControlFlowElement body, Location l | - body = this.asCallable(l).getBody() and + body = this.asCallable(l).getBody() or + objectInitEntry(this.asCallable(l), body) + | NearestLocation::nearestLocation(body, l, _) and result = body.getAControlFlowEntryNode() ) and