Skip to content

Commit 66565b3

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

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
@@ -1648,13 +1648,19 @@ private string getConstantString(Expr e) {
16481648
result = e.(TemplateElement).getValue()
16491649
}
16501650

1651+
pragma[nomagic]
1652+
private predicate hasConstantStringValue(Expr e) {
1653+
exists(getConstantString(e))
1654+
or
1655+
hasAllConstantLeafs(e.getUnderlyingValue())
1656+
}
1657+
16511658
/**
16521659
* Holds if `add` is a string-concatenation where all the transitive leafs have a constant string value.
16531660
*/
16541661
private predicate hasAllConstantLeafs(AddExpr add) {
1655-
forex(Expr leaf | leaf = getAnAddOperand*(add) and not exists(getAnAddOperand(leaf)) |
1656-
exists(getConstantString(leaf))
1657-
)
1662+
hasConstantStringValue(add.getLeftOperand()) and
1663+
hasConstantStringValue(add.getRightOperand())
16581664
}
16591665

16601666
/**

0 commit comments

Comments
 (0)