Skip to content

Commit 5270565

Browse files
committed
Fixed advanced debug expression crash
1 parent ab8c307 commit 5270565

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

vpr/src/draw/draw_debug.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,8 @@ bool valid_expression(std::string exp) {
752752
}
753753

754754
//if expression started or ended with a bool operand or vector has and even number of operators (since in a valid expression number of operators are always odd)
755-
if (ops[0] == BOOL_OP || ops[ops.size() - 1] == BOOL_OP || ops.size() % 2 == 0)
755+
//checks if ops is empty first so trying to access ops[0] doesn't produce a seg fault
756+
if (ops.size() == 0 || ops[0] == BOOL_OP || ops[ops.size() - 1] == BOOL_OP || ops.size() % 2 == 0)
756757
return false;
757758

758759
//checks pattern (should be 0 1 0 1 0 ...) since in a valid expression comperator operators and bool operators are used in that pattern (e.g move_num == 3 || from_block == 11)
@@ -762,6 +763,7 @@ bool valid_expression(std::string exp) {
762763
else if (j % 2 != 0 && ops[j] == COMP_OP)
763764
return false;
764765
}
766+
765767
return true;
766768
}
767769

0 commit comments

Comments
 (0)