diff options
Diffstat (limited to 'contrib/tools/python3/Modules/arraymodule.c')
| -rw-r--r-- | contrib/tools/python3/Modules/arraymodule.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/contrib/tools/python3/Modules/arraymodule.c b/contrib/tools/python3/Modules/arraymodule.c index d24c5989af3..090a7b841c9 100644 --- a/contrib/tools/python3/Modules/arraymodule.c +++ b/contrib/tools/python3/Modules/arraymodule.c @@ -2966,11 +2966,16 @@ array_arrayiterator___setstate__(arrayiterobject *self, PyObject *state) Py_ssize_t index = PyLong_AsSsize_t(state); if (index == -1 && PyErr_Occurred()) return NULL; - if (index < 0) - index = 0; - else if (index > Py_SIZE(self->ao)) - index = Py_SIZE(self->ao); /* iterator exhausted */ - self->index = index; + arrayobject *ao = self->ao; + if (ao != NULL) { + if (index < 0) { + index = 0; + } + else if (index > Py_SIZE(ao)) { + index = Py_SIZE(ao); /* iterator exhausted */ + } + self->index = index; + } Py_RETURN_NONE; } |
