mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
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.
This commit is contained in:
parent
6d3db7000e
commit
3986d4e660
1 changed files with 2 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue