Skip to content

Commit 350b239

Browse files
committed
C++: Fix cartesian product in 'simple_comparison_eq'.
1 parent 0c3d9f7 commit 350b239

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,10 +722,12 @@ private predicate simple_comparison_eq(
722722

723723
/** Rearrange various simple comparisons into `op == k` form. */
724724
private predicate simple_comparison_eq(Instruction test, Operand op, int k, AbstractValue value) {
725-
exists(SwitchInstruction switch |
725+
exists(SwitchInstruction switch, CaseEdge case |
726726
test = switch.getExpression() and
727727
op.getDef() = test and
728-
value.(MatchValue).getCase().getValue().toInt() = k
728+
case = value.(MatchValue).getCase() and
729+
exists(switch.getSuccessor(case)) and
730+
case.getValue().toInt() = k
729731
)
730732
}
731733

0 commit comments

Comments
 (0)