diff --git a/python/repeated.c b/python/repeated.c index 7d797f2a31..b063fcf15c 100644 --- a/python/repeated.c +++ b/python/repeated.c @@ -61,7 +61,7 @@ static bool IndexToRange(PyObject* index, Py_ssize_t size, Py_ssize_t* i, *step = 0; *count = 1; - if (*i < 0 || *i >= size) { + if (*i < 0 || size <= *i) { PyErr_Format(PyExc_IndexError, "list index out of range"); return false; } diff --git a/upb/reflection.c b/upb/reflection.c index 1792adba36..3f986d5c2b 100644 --- a/upb/reflection.c +++ b/upb/reflection.c @@ -398,7 +398,7 @@ bool upb_array_insert(upb_array *arr, size_t i, size_t count, */ void upb_array_delete(upb_array *arr, size_t i, size_t count) { size_t end = i + count; - UPB_ASSERT(end >= i); + UPB_ASSERT(i <= end); UPB_ASSERT(end <= arr->len); upb_array_move(arr, i, end, arr->len - end); arr->len -= count;