mirror of
https://github.com/python/cpython.git
synced 2026-05-08 13:40:46 -04:00
gh-115733: Fix crash involving exhausted list iterator (#115740)
* gh-115733: Fix crash involving exhausted iterator * Add blurb
This commit is contained in:
+2
-1
@@ -2612,7 +2612,7 @@ dummy_func(
|
||||
assert(Py_TYPE(iter) == &PyListIter_Type);
|
||||
STAT_INC(FOR_ITER, hit);
|
||||
PyListObject *seq = it->it_seq;
|
||||
if ((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq)) {
|
||||
if (seq == NULL || (size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq)) {
|
||||
it->it_index = -1;
|
||||
#ifndef Py_GIL_DISABLED
|
||||
if (seq != NULL) {
|
||||
@@ -2633,6 +2633,7 @@ dummy_func(
|
||||
_PyListIterObject *it = (_PyListIterObject *)iter;
|
||||
assert(Py_TYPE(iter) == &PyListIter_Type);
|
||||
PyListObject *seq = it->it_seq;
|
||||
DEOPT_IF(seq == NULL);
|
||||
DEOPT_IF((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq));
|
||||
}
|
||||
|
||||
|
||||
Generated
+1
@@ -2427,6 +2427,7 @@
|
||||
_PyListIterObject *it = (_PyListIterObject *)iter;
|
||||
assert(Py_TYPE(iter) == &PyListIter_Type);
|
||||
PyListObject *seq = it->it_seq;
|
||||
if (seq == NULL) goto deoptimize;
|
||||
if ((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq)) goto deoptimize;
|
||||
break;
|
||||
}
|
||||
|
||||
Generated
+1
-1
@@ -2560,7 +2560,7 @@
|
||||
assert(Py_TYPE(iter) == &PyListIter_Type);
|
||||
STAT_INC(FOR_ITER, hit);
|
||||
PyListObject *seq = it->it_seq;
|
||||
if ((size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq)) {
|
||||
if (seq == NULL || (size_t)it->it_index >= (size_t)PyList_GET_SIZE(seq)) {
|
||||
it->it_index = -1;
|
||||
#ifndef Py_GIL_DISABLED
|
||||
if (seq != NULL) {
|
||||
|
||||
Reference in New Issue
Block a user