From 25dded041fe532fcb041b6e68582bf76b4968132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Wed, 5 Mar 2014 13:47:57 +0000 Subject: Make the various iterators' "setstate" sliently and consistently clip the index. This avoids the possibility of setting an iterator to an invalid state. --- Modules/arraymodule.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Modules/arraymodule.c') diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 96c9e5bba7..3aba9adbeb 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -2798,6 +2798,8 @@ arrayiter_setstate(arrayiterobject *it, PyObject *state) return NULL; if (index < 0) index = 0; + else if (index > Py_SIZE(it->ao)) + index = Py_SIZE(it->ao); /* iterator exhausted */ it->index = index; Py_RETURN_NONE; } -- cgit v1.2.1