]> granicus.if.org Git - python/commitdiff
Check return of PyMem_MALLOC (garbage) is non-NULL.
authorNeal Norwitz <nnorwitz@gmail.com>
Sat, 12 Aug 2006 03:16:54 +0000 (03:16 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sat, 12 Aug 2006 03:16:54 +0000 (03:16 +0000)
Check seq in both portions of if/else.

Klocwork #289-290.

Objects/listobject.c

index e6bed7172a894a61879a81b3407c4f494fb43aaa..f917385fa0f3f407f83ea2b4794f3753f80b55bf 100644 (file)
@@ -2541,6 +2541,10 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
 
                        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 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
                        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,