Skip to content

Commit 403e868

Browse files
committed
Don't mistake a rule case for a fall-through edge
1 parent 5243a62 commit 403e868

File tree

1 file changed

+6
-2
lines changed
  • java/ql/lib/semmle/code/java/controlflow

1 file changed

+6
-2
lines changed

java/ql/lib/semmle/code/java/controlflow/Guards.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,12 @@ private predicate isNonFallThroughPredecessor(SwitchCase sc, ControlFlowNode pre
123123
previousPatternCase = getClosestPrecedingPatternCase(sc)
124124
|
125125
pred.(Expr).getParent*() = previousPatternCase.getGuard() and
126-
// Check there is any statement in between the previous pattern case and this one.
127-
not previousPatternCase.getIndex() = sc.getIndex() - 1
126+
// Check there is any statement in between the previous pattern case and this one,
127+
// or the case is a rule, so there is no chance of a fall-through.
128+
(
129+
previousPatternCase.isRule() or
130+
not previousPatternCase.getIndex() = sc.getIndex() - 1
131+
)
128132
)
129133
or
130134
// Unambigious: on the test-passing edge there must be at least one intervening

0 commit comments

Comments
 (0)