summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2019-09-09 20:40:58 (GMT)
committerT. Wouters <thomas@python.org>2019-09-09 20:40:58 (GMT)
commit755d4ef8243050e5ff973524633caebd0ce03af9 (patch)
tree027ad798be7f4f621a8d42569609a6b189f2a929
parent832e8640086ac4fa547c055a72929879cc5a963a (diff)
downloadcpython-755d4ef8243050e5ff973524633caebd0ce03af9.zip
cpython-755d4ef8243050e5ff973524633caebd0ce03af9.tar.gz
cpython-755d4ef8243050e5ff973524633caebd0ce03af9.tar.bz2
Correct overflow check in PyTuple_New() (GH-14838)
-rw-r--r--Objects/tupleobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index a72257f..08f7022 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -120,8 +120,8 @@ tuple_alloc(Py_ssize_t size)
#endif
{
/* Check for overflow */
- if ((size_t)size > ((size_t)PY_SSIZE_T_MAX - sizeof(PyTupleObject) -
- sizeof(PyObject *)) / sizeof(PyObject *)) {
+ if ((size_t)size > ((size_t)PY_SSIZE_T_MAX - (sizeof(PyTupleObject) -
+ sizeof(PyObject *))) / sizeof(PyObject *)) {
return (PyTupleObject *)PyErr_NoMemory();
}
op = PyObject_GC_NewVar(PyTupleObject, &PyTuple_Type, size);