Skip to content

Commit 2b24d6d

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

File tree

1 file changed

+9
-3
lines changed
  • javascript/ql/lib/semmle/javascript

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,13 +1618,19 @@ private string getConstantString(Expr e) {
16181618
result = e.(TemplateElement).getValue()
16191619
}
16201620

1621+
pragma[nomagic]
1622+
private predicate hasConstantStringValue(Expr e) {
1623+
exists(getConstantString(e))
1624+
or
1625+
hasAllConstantLeafs(e.getUnderlyingValue())
1626+
}
1627+
16211628
/**
16221629
* Holds if `add` is a string-concatenation where all the transitive leafs have a constant string value.
16231630
*/
16241631
private predicate hasAllConstantLeafs(AddExpr add) {
1625-
forex(Expr leaf | leaf = getAnAddOperand*(add) and not exists(getAnAddOperand(leaf)) |
1626-
exists(getConstantString(leaf))
1627-
)
1632+
hasConstantStringValue(add.getLeftOperand()) and
1633+
hasConstantStringValue(add.getRightOperand())
16281634
}
16291635

16301636
/**

0 commit comments

Comments
 (0)