Commit d6436cd4 authored by Neal Norwitz's avatar Neal Norwitz

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

Check seq in both portions of if/else.

Klocwork #289-290.
parent 86507b2e
...@@ -2541,6 +2541,10 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value) ...@@ -2541,6 +2541,10 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
garbage = (PyObject**) garbage = (PyObject**)
PyMem_MALLOC(slicelength*sizeof(PyObject*)); PyMem_MALLOC(slicelength*sizeof(PyObject*));
if (!garbage) {
PyErr_NoMemory();
return -1;
}
/* drawing pictures might help /* drawing pictures might help
understand these for loops */ understand these for loops */
...@@ -2589,9 +2593,9 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value) ...@@ -2589,9 +2593,9 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
else { else {
seq = PySequence_Fast(value, seq = PySequence_Fast(value,
"must assign iterable to extended slice"); "must assign iterable to extended slice");
if (!seq)
return -1;
} }
if (!seq)
return -1;
if (PySequence_Fast_GET_SIZE(seq) != slicelength) { if (PySequence_Fast_GET_SIZE(seq) != slicelength) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment