]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Backport rev. 46878 by neal.norwitz]
authorAndrew M. Kuchling <amk@amk.ca>
Fri, 29 Sep 2006 18:22:07 +0000 (18:22 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Fri, 29 Sep 2006 18:22:07 +0000 (18:22 +0000)
Don't leak the list object if there's an error allocating the item
storage.  Backport candidate.

Objects/listobject.c

index 3b7358a312ec8f2a665501ea224e593ad1e57477..b0bc6a8c3167f1b420f6cffcc7d935bf7e5066bd 100644 (file)
@@ -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;