summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-10-11 21:05:56 (GMT)
committerGuido van Rossum <guido@python.org>2002-10-11 21:05:56 (GMT)
commita5c0e6d6c8e3513017009796ff34bb9c14512559 (patch)
treefbaef612dddda4c7e7521ff184270d96ea427cf5 /Objects/listobject.c
parent6e08c1460c79962a98e106437a089d2fe306403c (diff)
downloadcpython-a5c0e6d6c8e3513017009796ff34bb9c14512559.zip
cpython-a5c0e6d6c8e3513017009796ff34bb9c14512559.tar.gz
cpython-a5c0e6d6c8e3513017009796ff34bb9c14512559.tar.bz2
Add checks for size overflow on list*n, list+list, tuple+tuple.
Will backport.
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 64de38b..2cb08d3 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -391,6 +391,8 @@ list_concat(PyListObject *a, PyObject *bb)
}
#define b ((PyListObject *)bb)
size = a->ob_size + b->ob_size;
+ if (size < 0)
+ return PyErr_NoMemory();
np = (PyListObject *) PyList_New(size);
if (np == NULL) {
return NULL;
@@ -419,6 +421,8 @@ list_repeat(PyListObject *a, int n)
if (n < 0)
n = 0;
size = a->ob_size * n;
+ if (size/a->ob_size != n)
+ return PyErr_NoMemory();
np = (PyListObject *) PyList_New(size);
if (np == NULL)
return NULL;