Skip to content

Commit 1decdaf

Browse files
committed
JS: Fix accidental recursion
1 parent 1a7d9f1 commit 1decdaf

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

javascript/ql/lib/semmle/javascript/dataflow/internal/sharedlib/SummaryTypeTracker.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,16 @@ private module SummaryFlowConfig implements Input {
3030
}
3131

3232
Node argumentOf(Node call, SummaryComponent arg, boolean isPostUpdate) {
33+
// Note: we cannot rely on DataFlowPrivate::DataFlowCall here because that depends on the call graph.
3334
exists(ArgumentPosition apos, ParameterPosition ppos, Node argNode |
3435
arg = argument(ppos) and
3536
parameterMatch(ppos, apos) and
36-
isArgumentNode(argNode, any(DataFlowCall c | c.asOrdinaryCall() = call), apos)
37+
(
38+
argNode = call.(DataFlow::InvokeNode).getArgument(apos.asPositional())
39+
or
40+
apos.isThis() and
41+
argNode = call.(DataFlow::CallNode).getReceiver()
42+
)
3743
|
3844
isPostUpdate = true and result = argNode.getPostUpdateNode()
3945
or
@@ -42,11 +48,15 @@ private module SummaryFlowConfig implements Input {
4248
}
4349

4450
Node parameterOf(Node callable, SummaryComponent param) {
45-
exists(ArgumentPosition apos, ParameterPosition ppos, Function function |
51+
exists(ArgumentPosition apos, ParameterPosition ppos, DataFlow::FunctionNode function |
4652
param = parameter(apos) and
4753
parameterMatch(ppos, apos) and
48-
callable = function.flow() and
49-
isParameterNode(result, any(DataFlowCallable c | c.asSourceCallable() = function), ppos)
54+
callable = function
55+
|
56+
result = function.getParameter(ppos.asPositional())
57+
or
58+
ppos.isThis() and
59+
result = function.getReceiver()
5060
)
5161
}
5262

0 commit comments

Comments
 (0)