mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-115733: Fix crash involving exhausted list iterator (#115740)
* gh-115733: Fix crash involving exhausted iterator * Add blurb
This commit is contained in:
parent
494739e1f7
commit
520403ed4c
6 changed files with 13 additions and 5 deletions
|
|
@ -3537,13 +3537,13 @@ listreviter_next(PyObject *self)
|
|||
{
|
||||
listreviterobject *it = (listreviterobject *)self;
|
||||
assert(it != NULL);
|
||||
PyListObject *seq = it->it_seq;
|
||||
assert(PyList_Check(seq));
|
||||
|
||||
Py_ssize_t index = LOAD_SSIZE(it->it_index);
|
||||
if (index < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyListObject *seq = it->it_seq;
|
||||
assert(PyList_Check(seq));
|
||||
PyObject *item = list_get_item_ref(seq, index);
|
||||
if (item != NULL) {
|
||||
STORE_SSIZE(it->it_index, index - 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue