Skip to content

Commit 799c945

Browse files
committed
Ruby: fix CFG for AsPattern
1 parent 95f8f85 commit 799c945

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

ruby/ql/lib/codeql/ruby/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -696,11 +696,24 @@ module Trees {
696696
}
697697
}
698698

699-
private class AsPatternTree extends StandardPreOrderTree, AsPattern {
700-
override ControlFlowTree getChildElement(int i) {
701-
result = this.getPattern() and i = 0
699+
private class AsPatternTree extends PreOrderTree, AsPattern {
700+
final override predicate propagatesAbnormal(AstNode child) { child = this.getPattern() }
701+
702+
final override predicate last(AstNode last, Completion c) {
703+
last(this.getPattern(), last, c) and
704+
c.(MatchingCompletion).getValue() = false
705+
or
706+
last(this.getVariableAccess(), last, c)
707+
}
708+
709+
final override predicate succ(AstNode pred, AstNode succ, Completion c) {
710+
pred = this and
711+
first(this.getPattern(), succ) and
712+
c instanceof SimpleCompletion
702713
or
703-
result = this.getVariableAccess() and i = 1
714+
last(this.getPattern(), pred, c) and
715+
first(this.getVariableAccess(), succ) and
716+
c.(MatchingCompletion).getValue() = true
704717
}
705718
}
706719

0 commit comments

Comments
 (0)