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

andrew.kuchling python-checkins at python.org
Tue Oct 3 21:07:06 CEST 2006


Author: andrew.kuchling
Date: Tue Oct  3 21:07:06 2006
New Revision: 52112

Modified:
   python/branches/release24-maint/Objects/listobject.c
Log:
[Backport r51230 | neal.norwitz]

Check return of PyMem_MALLOC (garbage) is non-NULL.
Check seq in both portions of if/else.

Klocwork #289-290.



Modified: python/branches/release24-maint/Objects/listobject.c
==============================================================================
--- python/branches/release24-maint/Objects/listobject.c	(original)
+++ python/branches/release24-maint/Objects/listobject.c	Tue Oct  3 21:07:06 2006
@@ -2550,6 +2550,10 @@
 
 			garbage = (PyObject**)
 				PyMem_MALLOC(slicelength*sizeof(PyObject*));
+			if (!garbage) {
+				PyErr_NoMemory();
+				return -1;
+			}
 
 			/* drawing pictures might help
 			   understand these for loops */
@@ -2598,9 +2602,9 @@
 			else {
 				seq = PySequence_Fast(value,
 					"must assign iterable to extended slice");
-				if (!seq)
-					return -1;
 			}
+			if (!seq)
+				return -1;
 
 			if (PySequence_Fast_GET_SIZE(seq) != slicelength) {
 				PyErr_Format(PyExc_ValueError,


More information about the Python-checkins mailing list