summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 7ea979c..bba27dd 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -3630,6 +3630,12 @@ dictiter_iternextvalue(dictiterobject *di)
goto fail;
value = entry_ptr->me_value;
}
+ // We found an element, but did not expect it
+ if (di->len == 0) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "dictionary keys changed during iteration");
+ goto fail;
+ }
di->di_pos = i+1;
di->len--;
Py_INCREF(value);
@@ -3713,6 +3719,12 @@ dictiter_iternextitem(dictiterobject *di)
key = entry_ptr->me_key;
value = entry_ptr->me_value;
}
+ // We found an element, but did not expect it
+ if (di->len == 0) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "dictionary keys changed during iteration");
+ goto fail;
+ }
di->di_pos = i+1;
di->len--;
Py_INCREF(key);