From: Neal Norwitz Date: Mon, 12 Jun 2006 02:08:41 +0000 (+0000) Subject: Don't leak the list object if there's an error allocating the item storage. Backport... X-Git-Tag: v2.5b1~115 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a00c0b97bf2772ec65f322517ade729dcbcc1cf1;p=thirdparty%2FPython%2Fcpython.git Don't leak the list object if there's an error allocating the item storage. Backport candidate --- diff --git a/Objects/listobject.c b/Objects/listobject.c index 105df4cb2e5f..e6bed7172a89 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -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;