summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2011-09-19 18:19:50 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2011-09-19 18:19:50 (GMT)
commit8f53d092f23d063b19a9377fbb7d1d2f62ad77c9 (patch)
tree3c32ce5f7b7aaa3dfbbce24a0745d526f3c611da /Objects/listobject.c
parenta372de8408b28689c63cb5ec711e2dceffc05e92 (diff)
parentc0420fd42ade6d996bfe2ae2beffa3de79524883 (diff)
downloadcpython-8f53d092f23d063b19a9377fbb7d1d2f62ad77c9.zip
cpython-8f53d092f23d063b19a9377fbb7d1d2f62ad77c9.tar.gz
cpython-8f53d092f23d063b19a9377fbb7d1d2f62ad77c9.tar.bz2
Merge issue #12973 list_repeat fix.
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 2cd8642..cada708 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -58,7 +58,7 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
if (newsize == 0)
new_allocated = 0;
items = self->ob_item;
- if (new_allocated <= ((~(size_t)0) / sizeof(PyObject *)))
+ if (new_allocated <= (PY_SIZE_MAX / sizeof(PyObject *)))
PyMem_RESIZE(items, PyObject *, new_allocated);
else
items = NULL;
@@ -510,9 +510,9 @@ list_repeat(PyListObject *a, Py_ssize_t n)
PyObject *elem;
if (n < 0)
n = 0;
- size = Py_SIZE(a) * n;
- if (n && size/n != Py_SIZE(a))
+ if (n > 0 && Py_SIZE(a) > PY_SSIZE_T_MAX / n)
return PyErr_NoMemory();
+ size = Py_SIZE(a) * n;
if (size == 0)
return PyList_New(0);
np = (PyListObject *) PyList_New(size);