[Python-checkins] r51230 - python/trunk/Objects/listobject.c

neal.norwitz python-checkins at python.org
Sat Aug 12 05:16:56 CEST 2006


Author: neal.norwitz
Date: Sat Aug 12 05:16:54 2006
New Revision: 51230

Modified:
   python/trunk/Objects/listobject.c
Log:
Check return of PyMem_MALLOC (garbage) is non-NULL.
Check seq in both portions of if/else.

Klocwork #289-290.


Modified: python/trunk/Objects/listobject.c
==============================================================================
--- python/trunk/Objects/listobject.c	(original)
+++ python/trunk/Objects/listobject.c	Sat Aug 12 05:16:54 2006
@@ -2541,6 +2541,10 @@
 
 			garbage = (PyObject**)
 				PyMem_MALLOC(slicelength*sizeof(PyObject*));
+			if (!garbage) {
+				PyErr_NoMemory();
+				return -1;
+			}
 
 			/* drawing pictures might help
 			   understand these for loops */
@@ -2589,9 +2593,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