From: Andrew M. Kuchling Date: Tue, 3 Oct 2006 19:07:06 +0000 (+0000) Subject: [Backport r51230 | neal.norwitz] X-Git-Tag: v2.4.4c1~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59e0e1e39541866b2897c5d1002d49aedf79f393;p=thirdparty%2FPython%2Fcpython.git [Backport r51230 | neal.norwitz] Check return of PyMem_MALLOC (garbage) is non-NULL. Check seq in both portions of if/else. Klocwork #289-290. --- diff --git a/Objects/listobject.c b/Objects/listobject.c index b0bc6a8c3167..40d46203d223 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2550,6 +2550,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 */ @@ -2598,9 +2602,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,