mirror of
https://github.com/python/cpython.git
synced 2025-09-13 12:17:24 +00:00
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
1 changed files with 3 additions and 1 deletions
|
@ -108,8 +108,10 @@ PyList_New(Py_ssize_t size)
|
||||||
op->ob_item = NULL;
|
op->ob_item = NULL;
|
||||||
else {
|
else {
|
||||||
op->ob_item = (PyObject **) PyMem_MALLOC(nbytes);
|
op->ob_item = (PyObject **) PyMem_MALLOC(nbytes);
|
||||||
if (op->ob_item == NULL)
|
if (op->ob_item == NULL) {
|
||||||
|
Py_DECREF(op);
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
}
|
||||||
memset(op->ob_item, 0, nbytes);
|
memset(op->ob_item, 0, nbytes);
|
||||||
}
|
}
|
||||||
op->ob_size = size;
|
op->ob_size = size;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue