JS: fix false positives for splice with conditional index decrement

This commit is contained in:
Napalys Klicius
2025-06-12 14:51:10 +02:00
parent 7292a76ee4
commit 66d66fe87d
3 changed files with 19 additions and 5 deletions

View File

@@ -146,7 +146,12 @@ class ArrayIterationLoop extends ForStmt {
or
this.hasPathThrough(splice, cfg.getAPredecessor()) and
this.getLoopEntry().dominates(cfg.getBasicBlock()) and
not this.hasIndexingManipulation(cfg)
not this.hasIndexingManipulation(cfg) and
// Don't continue through a branch that tests the splice call's return value
not exists(ConditionGuardNode guard | cfg = guard |
guard.getTest() = splice.asExpr() and
guard.getOutcome() = false
)
}
}