summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 5b75968..7d3732d 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -2811,6 +2811,8 @@ listiter_setstate(listiterobject *it, PyObject *state)
if (it->it_seq != NULL) {
if (index < 0)
index = 0;
+ else if (index > PyList_GET_SIZE(it->it_seq))
+ index = PyList_GET_SIZE(it->it_seq); /* iterator exhausted */
it->it_index = index;
}
Py_RETURN_NONE;