diff options
author | Tim Peters <tim.peters@gmail.com> | 2004-07-29 02:28:42 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2004-07-29 02:28:42 (GMT) |
commit | 3986d4e66022b8b1821f517723cf25ca98134d0e (patch) | |
tree | 2e0002405a674f14ac67fa9cde0a44ad3348352b | |
parent | 6d3db7000ee8f3a910e101bb5f622463af2b2b31 (diff) | |
download | cpython-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.
-rw-r--r-- | Objects/listobject.c | 3 |
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; |