From: Andrew M. Kuchling Date: Fri, 29 Sep 2006 18:22:07 +0000 (+0000) Subject: [Backport rev. 46878 by neal.norwitz] X-Git-Tag: v2.4.4c1~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=942f75df605c2ae17ae6b7a9a9eecc418d19fc39;p=thirdparty%2FPython%2Fcpython.git [Backport rev. 46878 by neal.norwitz] 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 3b7358a312ec..b0bc6a8c3167 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -108,8 +108,10 @@ PyList_New(int 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;