diff options
author | Thomas Perl <m@thp.io> | 2019-03-28 06:03:25 (GMT) |
---|---|---|
committer | Inada Naoki <songofacandy@gmail.com> | 2019-03-28 06:03:25 (GMT) |
commit | 796cc6e3ad3617c1ea9e528663aac1a206230a28 (patch) | |
tree | 0af419b927af85d970dc7f1c207e04a1744704cd /Objects | |
parent | 738cb42a14481aa9ae58704f6bee951308212d7e (diff) | |
download | cpython-796cc6e3ad3617c1ea9e528663aac1a206230a28.zip cpython-796cc6e3ad3617c1ea9e528663aac1a206230a28.tar.gz cpython-796cc6e3ad3617c1ea9e528663aac1a206230a28.tar.bz2 |
bpo-36452: dictiter: track maximum iteration count (GH-12596)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/dictobject.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c index e2603e1..7ea979c 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -3543,6 +3543,12 @@ dictiter_iternextkey(dictiterobject *di) goto fail; key = entry_ptr->me_key; } + // We found an element (key), 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); |