summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-08-12 03:16:54 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-08-12 03:16:54 (GMT)
commitb88cfad3181ba2eb6537edeb9a7d067970178d69 (patch)
treede7a68e111581b23ba0d03170e69c3aa94af7b2c /Objects/listobject.c
parent5f17d9a1dfe6db0d3e5069ff42b4e4fbfbc2aa2f (diff)
downloadcpython-b88cfad3181ba2eb6537edeb9a7d067970178d69.zip
cpython-b88cfad3181ba2eb6537edeb9a7d067970178d69.tar.gz
cpython-b88cfad3181ba2eb6537edeb9a7d067970178d69.tar.bz2
Check return of PyMem_MALLOC (garbage) is non-NULL.
Check seq in both portions of if/else. Klocwork #289-290.
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index e6bed71..f917385 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -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,