aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-12-29 22:53:37 +0000
committergingerBill <bill@gingerbill.org>2019-12-29 22:53:37 +0000
commit7e271310ff7a844270a981bb8fc1f961bb45f319 (patch)
tree9c540ae69f08be3fa36506751391f4255ecd6ece /src/check_expr.cpp
parentf24de51c65b583409c3f9791e4c98968cc6b0277 (diff)
Fix constant out of bounds bug
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index fa92604ee..bb76638ec 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -3119,13 +3119,12 @@ bool check_index_value(CheckerContext *c, bool open_range, Ast *index_value, i64
}
if (value) *value = v;
bool out_of_bounds = false;
- if (open_range) {
- out_of_bounds = v >= max_count;
- } else {
- out_of_bounds = v >= max_count+1;
- }
if (v < 0) {
out_of_bounds = true;
+ } else if (open_range) {
+ out_of_bounds = v > max_count;
+ } else {
+ out_of_bounds = v >= max_count;
}
if (out_of_bounds) {