Skip to content

Commit 052a8e7

Browse files
committed
JS: Avoid spurious recursion in AMD
1 parent 9ecac04 commit 052a8e7

File tree

1 file changed

+5
-4
lines changed
  • javascript/ql/lib/semmle/javascript

1 file changed

+5
-4
lines changed

javascript/ql/lib/semmle/javascript/AMD.qll

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
102102
/**
103103
* Holds if `p` is the parameter corresponding to dependency `dep`.
104104
*/
105-
predicate dependencyParameter(PathExpr dep, Parameter p) {
105+
predicate dependencyParameter(Expr dep, Parameter p) {
106106
exists(int i |
107-
dep = this.getDependency(i) and
107+
// Note: to avoid spurious recursion, do not depend on PathExpr here
108+
dep = this.getDependencies().getElement(i) and
108109
p = this.getFactoryParameter(i)
109110
)
110111
}
@@ -122,9 +123,9 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
122123
* `dep1` and `dep2`.
123124
*/
124125
Parameter getDependencyParameter(string name) {
125-
exists(PathExpr dep |
126+
exists(Expr dep |
126127
this.dependencyParameter(dep, result) and
127-
dep.getValue() = name
128+
name = dep.getStringValue()
128129
)
129130
}
130131

0 commit comments

Comments
 (0)