From 59e0e1e39541866b2897c5d1002d49aedf79f393 Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Tue, 3 Oct 2006 19:07:06 +0000 Subject: [Backport r51230 | neal.norwitz] Check return of PyMem_MALLOC (garbage) is non-NULL. Check seq in both portions of if/else. Klocwork #289-290. --- Objects/listobject.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index b0bc6a8..40d4620 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, -- cgit v0.12