summaryrefslogtreecommitdiffstats
path: root/Objects/tupleobject.c
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-07-25 02:39:20 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-07-25 02:39:20 (GMT)
commitb93d8637a6bce5b1b61423dc6c8319fc82a31b13 (patch)
tree2bf465e8c89e54dc4989f126b7b8c20008e455a9 /Objects/tupleobject.c
parent32d2ce3561088eb0fbb3e63e9fcbc3a90491604a (diff)
downloadcpython-b93d8637a6bce5b1b61423dc6c8319fc82a31b13.zip
cpython-b93d8637a6bce5b1b61423dc6c8319fc82a31b13.tar.gz
cpython-b93d8637a6bce5b1b61423dc6c8319fc82a31b13.tar.bz2
Issue #1621: Avoid signed overflow in list and tuple operations
Patch by Xiang Zhang.
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r--Objects/tupleobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 1b41258..c0ff499 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -453,9 +453,9 @@ tupleconcat(PyTupleObject *a, PyObject *bb)
return NULL;
}
#define b ((PyTupleObject *)bb)
- size = Py_SIZE(a) + Py_SIZE(b);
- if (size < 0)
+ if (Py_SIZE(a) > PY_SSIZE_T_MAX - Py_SIZE(b))
return PyErr_NoMemory();
+ size = Py_SIZE(a) + Py_SIZE(b);
np = (PyTupleObject *) PyTuple_New(size);
if (np == NULL) {
return NULL;