From 3986d4e66022b8b1821f517723cf25ca98134d0e Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Thu, 29 Jul 2004 02:28:42 +0000 Subject: 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. --- Objects/listobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; -- cgit v0.12