aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-02-20 15:18:44 -0500
committerGitHub <noreply@github.com>2024-02-21 05:18:44 +0900
commit520403ed4cdf4890d63403c9cf01ac63233f5ef4 (patch)
tree5a51e71547cbe711d8e067cdc65bb3fa1631e626 /Python/bytecodes.c
parent494739e1f71f8e290a2c869d4f40f4ea36a045c2 (diff)
downloadcpython-520403ed4cdf4890d63403c9cf01ac63233f5ef4.tar.gz
cpython-520403ed4cdf4890d63403c9cf01ac63233f5ef4.zip
gh-115733: Fix crash involving exhausted list iterator (#115740)
* gh-115733: Fix crash involving exhausted iterator * Add blurb
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 9d790a9d3e6..5835b80582b 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -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));
}