summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 494b401..1a210e7 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -3451,16 +3451,24 @@ listiter_reduce_general(void *_it, int forward)
/* the objects are not the same, index is of different types! */
if (forward) {
PyObject *iter = _PyEval_GetBuiltin(&_Py_ID(iter));
+ if (!iter) {
+ return NULL;
+ }
_PyListIterObject *it = (_PyListIterObject *)_it;
if (it->it_seq) {
return Py_BuildValue("N(O)n", iter, it->it_seq, it->it_index);
}
+ Py_DECREF(iter);
} else {
PyObject *reversed = _PyEval_GetBuiltin(&_Py_ID(reversed));
+ if (!reversed) {
+ return NULL;
+ }
listreviterobject *it = (listreviterobject *)_it;
if (it->it_seq) {
return Py_BuildValue("N(O)n", reversed, it->it_seq, it->it_index);
}
+ Py_DECREF(reversed);
}
/* empty iterator, create an empty list */
list = PyList_New(0);