summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2019-05-17 07:13:03 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2019-05-17 07:13:03 (GMT)
commit14514d9084a40f599c57da853a305aa264562a43 (patch)
tree36cb61b74dbfda9ce1cdf72a864b640d0bda546d /Objects/bytesobject.c
parent870b035bc6da96689b59dd6f79782ec6f1873617 (diff)
downloadcpython-14514d9084a40f599c57da853a305aa264562a43.zip
cpython-14514d9084a40f599c57da853a305aa264562a43.tar.gz
cpython-14514d9084a40f599c57da853a305aa264562a43.tar.bz2
bpo-36946: Fix possible signed integer overflow when handling slices. (GH-13375)
The final addition (cur += step) may overflow, so use size_t for "cur". "cur" is always positive (even for negative steps), so it is safe to use size_t here. Co-Authored-By: Martin Panter <vadmium+py@gmail.com>
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index b7c5b75..ebbdb7c 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -1677,7 +1677,8 @@ bytes_subscript(PyBytesObject* self, PyObject* item)
return PyLong_FromLong((unsigned char)self->ob_sval[i]);
}
else if (PySlice_Check(item)) {
- Py_ssize_t start, stop, step, slicelength, cur, i;
+ Py_ssize_t start, stop, step, slicelength, i;
+ size_t cur;
char* source_buf;
char* result_buf;
PyObject* result;