summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2008-01-25 19:42:36 (GMT)
committerGuido van Rossum <guido@python.org>2008-01-25 19:42:36 (GMT)
commitee6bab06d323b76a36833cbe65c857d279195e9a (patch)
tree1b5ff61d7637b3f1d53542e87d67baf4f89059cd /Objects
parent1c4282b41b853cd07b279b198e8002bc4ee323bf (diff)
downloadcpython-ee6bab06d323b76a36833cbe65c857d279195e9a.zip
cpython-ee6bab06d323b76a36833cbe65c857d279195e9a.tar.gz
cpython-ee6bab06d323b76a36833cbe65c857d279195e9a.tar.bz2
Rewrite the list_inline_repeat overflow check slightly differently.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/listobject.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index c0d0e09..10b099a 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -490,7 +490,7 @@ list_repeat(PyListObject *a, Py_ssize_t n)
if (n && size/n != a->ob_size)
return PyErr_NoMemory();
if (size == 0)
- return PyList_New(0);
+ return PyList_New(0);
np = (PyListObject *) PyList_New(size);
if (np == NULL)
return NULL;
@@ -672,10 +672,11 @@ list_inplace_repeat(PyListObject *self, Py_ssize_t n)
return (PyObject *)self;
}
- p = size*n;
- if (p/n != size)
+ if (size > SSIZE_MAX / n) {
return PyErr_NoMemory();
- if (list_resize(self, p) == -1)
+ }
+
+ if (list_resize(self, size*n) == -1)
return NULL;
p = size;