diff options
author | Raymond Hettinger <python@rcn.com> | 2015-03-01 08:38:00 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-03-01 08:38:00 (GMT) |
commit | 7f9ea7543ecc978a636f2b0b5b28e0820644a312 (patch) | |
tree | aa93e74e9b2c92fc19ff8d2337d514f188c380d1 /Modules | |
parent | 90295b450c7e4cca757f2c7f5536d21f06b1cef7 (diff) | |
download | cpython-7f9ea7543ecc978a636f2b0b5b28e0820644a312.zip cpython-7f9ea7543ecc978a636f2b0b5b28e0820644a312.tar.gz cpython-7f9ea7543ecc978a636f2b0b5b28e0820644a312.tar.bz2 |
Issue #23553: Use an unsigned cast to tighten-up the bounds checking logic.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_collectionsmodule.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 0ca9be1..69814bb 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -772,7 +772,7 @@ deque_item(dequeobject *deque, Py_ssize_t i) PyObject *item; Py_ssize_t n, index=i; - if (i < 0 || i >= Py_SIZE(deque)) { + if ((size_t)i >= (size_t)Py_SIZE(deque)) { PyErr_SetString(PyExc_IndexError, "deque index out of range"); return NULL; @@ -836,7 +836,7 @@ deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v) block *b; Py_ssize_t n, len=Py_SIZE(deque), halflen=(len+1)>>1, index=i; - if (i < 0 || i >= len) { + if ((size_t)i >= (size_t)len) { PyErr_SetString(PyExc_IndexError, "deque index out of range"); return -1; |