mirror of https://github.com/python/cpython.git
Don't leak the list object if there's an error allocating the item storage. Backport candidate
This commit is contained in:
parent
71e05f1e0c
commit
a00c0b97bf
|
@ -108,8 +108,10 @@ PyList_New(Py_ssize_t size)
|
|||
op->ob_item = NULL;
|
||||
else {
|
||||
op->ob_item = (PyObject **) PyMem_MALLOC(nbytes);
|
||||
if (op->ob_item == NULL)
|
||||
if (op->ob_item == NULL) {
|
||||
Py_DECREF(op);
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
memset(op->ob_item, 0, nbytes);
|
||||
}
|
||||
op->ob_size = size;
|
||||
|
|
Loading…
Reference in New Issue