summaryrefslogtreecommitdiff
path: root/Objects/listobject.c
diff options
context:
space:
mode:
authorKristján Valur Jónsson <sweskman@gmail.com>2014-03-05 13:47:57 +0000
committerKristján Valur Jónsson <sweskman@gmail.com>2014-03-05 13:47:57 +0000
commit25dded041fe532fcb041b6e68582bf76b4968132 (patch)
tree3c70fceb3fe5ef98a17b85aa94704d20eb5a853d /Objects/listobject.c
parent4ca688edeb07de955e1ef67c11f0e327f12ffa6e (diff)
downloadcpython-git-25dded041fe532fcb041b6e68582bf76b4968132.tar.gz
Make the various iterators' "setstate" sliently and consistently clip the
index. This avoids the possibility of setting an iterator to an invalid state.
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 6e0d094154..143c7b3788 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -2803,6 +2803,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;