Don't leak the list object if there's an error allocating the item storage. Backport candidate

This commit is contained in:
Neal Norwitz 2006-06-12 02:08:41 +00:00
parent 71e05f1e0c
commit a00c0b97bf
1 changed files with 3 additions and 1 deletions

View File

@ -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;