Check return of PyMem_MALLOC (garbage) is non-NULL.

Check seq in both portions of if/else.

Klocwork #289-290.
This commit is contained in:
Neal Norwitz 2006-08-12 03:16:54 +00:00
parent 5f17d9a1df
commit b88cfad318
1 changed files with 6 additions and 2 deletions

View 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 (PySequence_Fast_GET_SIZE(seq) != slicelength) {
PyErr_Format(PyExc_ValueError,