Skip to content

Commit c657a31

Browse files
committed
ruby: fix bad join
1 parent 9530ac6 commit c657a31

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ruby/ql/src/queries/variables/UninitializedLocal.ql

+7-5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ Expr evaluatingMention(LocalVariableReadAccess read) {
5151
result.(NotExpr).getOperand() = read
5252
}
5353

54+
predicate loopProtects(ConditionalLoop l, LocalVariableReadAccess read) {
55+
l.getCondition() = read.getVariable().getAnAccess() and
56+
l.entersLoopWhenConditionIs(false) and
57+
l.getAControlFlowNode().getBasicBlock().dominates(read.getAControlFlowNode().getBasicBlock())
58+
}
59+
5460
class RelevantLocalVariableReadAccess extends LocalVariableReadAccess {
5561
RelevantLocalVariableReadAccess() {
5662
not exists(MethodCall c |
@@ -76,11 +82,7 @@ class RelevantLocalVariableReadAccess extends LocalVariableReadAccess {
7682
not exists(ConditionalExpr c | factor(c.getCondition(), this.getVariable().getAnAccess()) |
7783
this = c.getBranch(true).getAChild*()
7884
) and
79-
not exists(ConditionalLoop l |
80-
l.getCondition() = this.getVariable().getAnAccess() and
81-
l.entersLoopWhenConditionIs(false) and
82-
l.getAControlFlowNode().getBasicBlock().dominates(this.getAControlFlowNode().getBasicBlock())
83-
)
85+
not exists(ConditionalLoop l | loopProtects(l, this))
8486
}
8587
}
8688

0 commit comments

Comments
 (0)