Skip to content

Commit 45b84ff

Browse files
committed
Rust: Ensure singleton
1 parent 4244a65 commit 45b84ff

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ private module StepsInput implements Impl::Private::StepsInputSig {
168168
or
169169
exists(ArgumentPosition pos, Expr arg |
170170
s.head() = Impl::Private::SummaryComponent::parameter(pos) and
171-
arg = getSourceNodeArgument(source, s.tail().head()) and
171+
arg = getSourceNodeArgument(source, s.tail().headOfSingleton()) and
172172
result.asParameter() = getCallable(arg).getParam(pos.getPosition())
173173
)
174174
or
175175
result.(RustDataFlow::PostUpdateNode).getPreUpdateNode().asExpr().getExpr() =
176-
getSourceNodeArgument(source, s.head())
176+
getSourceNodeArgument(source, s.headOfSingleton())
177177
}
178178

179179
RustDataFlow::Node getSinkNode(Input::SinkBase sink, Impl::Private::SummaryComponent sc) {

shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,9 @@ module Make<
709709
this = TConsSummaryComponentStack(result, _)
710710
}
711711

712+
/** Gets the head of this stack if it is a singleton. */
713+
SummaryComponent headOfSingleton() { this = TSingletonSummaryComponentStack(result) }
714+
712715
/** Gets the tail of this stack, if any. */
713716
SummaryComponentStack tail() { this = TConsSummaryComponentStack(_, result) }
714717

0 commit comments

Comments
 (0)