Changed the style of a few range checks.

pull/13171/head
Joshua Haberman 3 years ago
parent 5f0978abb7
commit 80776e363d
  1. 2
      python/repeated.c
  2. 2
      upb/reflection.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;
}

@ -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;

Loading…
Cancel
Save