Skip to content

Commit b78a78f

Browse files
committed
JS: Move logic out of charpred and fields
Fields should typically only be used when they are uniquely determined by 'this'. But SharedFlowStep is a unit class and the fields can thus have surprising behaviour.
1 parent da9cb2a commit b78a78f

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

‎javascript/ql/lib/semmle/javascript/dataflow/internal/FunctionWrapperSteps.qll‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,9 @@ DataFlow::SourceNode trackWrappedFunction(DataFlow::SourceNode func) {
173173
* modeled.
174174
*/
175175
private class FunctionWrapperCallStep extends DataFlow::SharedFlowStep {
176-
DataFlow::CallNode call;
177-
DataFlow::FunctionNode wrapped;
178-
179-
FunctionWrapperCallStep() { call = trackWrappedFunction(wrapped).getACall() }
180-
181176
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
182-
exists(int index |
183-
// getArgument only has a result when the argument position is statically known.
177+
exists(DataFlow::CallNode call, DataFlow::FunctionNode wrapped, int index |
178+
call = trackWrappedFunction(wrapped).getACall() and
184179
pred = call.getArgument(index) and
185180
succ = wrapped.getParameter(index) and
186181
// A rest parameter receives an array, not the argument at this index.

0 commit comments

Comments
 (0)