Skip to content

Commit 3d59d2c

Browse files
committed
JS: Avoid bad join in shared predicate induced by 'forex'.
Use manual recursion instead.
1 parent 2acb7b5 commit 3d59d2c

File tree

1 file changed

+12
-2
lines changed
  • javascript/ql/lib/semmle/javascript

1 file changed

+12
-2
lines changed

javascript/ql/lib/semmle/javascript/Expr.qll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,8 +1652,18 @@ private string getConstantString(Expr e) {
16521652
* Holds if `add` is a string-concatenation where all the transitive leafs have a constant string value.
16531653
*/
16541654
private predicate hasAllConstantLeafs(AddExpr add) {
1655-
forex(Expr leaf | leaf = getAnAddOperand*(add) and not exists(getAnAddOperand(leaf)) |
1656-
exists(getConstantString(leaf))
1655+
exists(getConstantString(add.getLeftOperand())) and
1656+
exists(getConstantString(add.getRightOperand()))
1657+
or
1658+
(
1659+
hasAllConstantLeafs(add.getLeftOperand().getUnderlyingValue()) and
1660+
hasAllConstantLeafs(add.getRightOperand().getUnderlyingValue())
1661+
or
1662+
hasAllConstantLeafs(add.getLeftOperand()) and
1663+
exists(getConstantString(add.getRightOperand()))
1664+
or
1665+
hasAllConstantLeafs(add.getRightOperand()) and
1666+
exists(getConstantString(add.getLeftOperand()))
16571667
)
16581668
}
16591669

0 commit comments

Comments
 (0)