[Python-checkins] r52043 - python/branches/release24-maint/Objects/listobject.c

andrew.kuchling python-checkins at python.org
Fri Sep 29 20:22:08 CEST 2006


Author: andrew.kuchling
Date: Fri Sep 29 20:22:07 2006
New Revision: 52043

Modified:
   python/branches/release24-maint/Objects/listobject.c
Log:
[Backport rev. 46878 by neal.norwitz]

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



Modified: python/branches/release24-maint/Objects/listobject.c
==============================================================================
--- python/branches/release24-maint/Objects/listobject.c	(original)
+++ python/branches/release24-maint/Objects/listobject.c	Fri Sep 29 20:22:07 2006
@@ -108,8 +108,10 @@
 		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;


More information about the Python-checkins mailing list