summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2019-04-03 18:59:51 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2019-04-03 18:59:51 (GMT)
commitfd83a823a6f268dc97ee2bf7d8a1a88d948446e5 (patch)
treebe7275338e9e9a721882eafca2c1f48ae6b88693 /Modules
parenta110817c080ca3c2f3262350b5d7e0c0582527e6 (diff)
downloadcpython-fd83a823a6f268dc97ee2bf7d8a1a88d948446e5.zip
cpython-fd83a823a6f268dc97ee2bf7d8a1a88d948446e5.tar.gz
cpython-fd83a823a6f268dc97ee2bf7d8a1a88d948446e5.tar.bz2
bpo-36504: Fix signed integer overflow in _ctypes.c's PyCArrayType_new(). (GH-12660) (GH-12678)
(cherry picked from commit 487b73ab39c80157474821ef9083f51e0846bd62)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 33e2243..d608100 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -1534,7 +1534,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
itemsize = itemdict->size;
- if (length * itemsize < 0) {
+ if (length > PY_SSIZE_T_MAX / itemsize) {
PyErr_SetString(PyExc_OverflowError,
"array too large");
Py_DECREF(stgdict);