]> granicus.if.org Git - python/commitdiff
Don't leak the list object if there's an error allocating the item storage. Backport...
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 12 Jun 2006 02:08:41 +0000 (02:08 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 12 Jun 2006 02:08:41 +0000 (02:08 +0000)
Objects/listobject.c

index 105df4cb2e5f6a80ab0ec367f4cefaae83f5aae7..e6bed7172a894a61879a81b3407c4f494fb43aaa 100644 (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;