Skip to content

Commit a4e1860

Browse files
authored
Merge pull request #115 from microsoft/powershell-fix-dead-end-for-stmt
Powershell fix dead end for stmt
2 parents 7e66dc3 + 7ef8bfa commit a4e1860

File tree

3 files changed

+805
-2390
lines changed

3 files changed

+805
-2390
lines changed

powershell/ql/lib/semmle/code/powershell/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,16 @@ module Trees {
343343
final override predicate succ(AstNode pred, AstNode succ, Completion c) {
344344
// Start with initialization
345345
this = pred and
346-
first(super.getInitializer(), succ) and
346+
(
347+
first(super.getInitializer(), succ)
348+
or
349+
not exists(super.getInitializer()) and
350+
first(super.getCondition(), succ)
351+
or
352+
not exists(super.getInitializer()) and
353+
not exists(super.getCondition()) and
354+
first(this.getBody(), succ)
355+
) and
347356
completionIsSimple(c)
348357
or
349358
// Initialization -> condition
@@ -359,7 +368,16 @@ module Trees {
359368
// Body -> iterator
360369
last(this.getBody(), pred, c) and
361370
completionIsNormal(c) and
362-
first(super.getIterator(), succ)
371+
(
372+
first(super.getIterator(), succ)
373+
or
374+
not exists(super.getIterator()) and
375+
first(super.getCondition(), succ)
376+
or
377+
not exists(super.getIterator()) and
378+
not exists(super.getCondition()) and
379+
first(this.getBody(), succ)
380+
)
363381
or
364382
// Iterator -> condition
365383
last(super.getIterator(), pred, c) and

0 commit comments

Comments
 (0)