summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-07-29 02:28:42 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-07-29 02:28:42 (GMT)
commit3986d4e66022b8b1821f517723cf25ca98134d0e (patch)
tree2e0002405a674f14ac67fa9cde0a44ad3348352b /Objects
parent6d3db7000ee8f3a910e101bb5f622463af2b2b31 (diff)
downloadcpython-3986d4e66022b8b1821f517723cf25ca98134d0e.zip
cpython-3986d4e66022b8b1821f517723cf25ca98134d0e.tar.gz
cpython-3986d4e66022b8b1821f517723cf25ca98134d0e.tar.bz2
PyList_New(): we went to all the trouble of computing and bounds-checking
the size_t nbytes, and passed nbytes to malloc, so it was confusing to effectively recompute the same thing from scratch in the memset call.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/listobject.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index ac8cd33..4db3070 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -59,6 +59,7 @@ PyList_New(int size)
{
PyListObject *op;
size_t nbytes;
+
if (size < 0) {
PyErr_BadInternalCall();
return NULL;
@@ -82,7 +83,7 @@ PyList_New(int size)
op->ob_item = (PyObject **) PyMem_MALLOC(nbytes);
if (op->ob_item == NULL)
return PyErr_NoMemory();
- memset(op->ob_item, 0, sizeof(*op->ob_item) * size);
+ memset(op->ob_item, 0, nbytes);
}
op->ob_size = size;
op->allocated = size;