commit | 796cc6e3ad3617c1ea9e528663aac1a206230a28 | [log] [tgz] |
---|---|---|
author | Thomas Perl <m@thp.io> | Thu Mar 28 07:03:25 2019 +0100 |
committer | Inada Naoki <songofacandy@gmail.com> | Thu Mar 28 15:03:25 2019 +0900 |
tree | 0af419b927af85d970dc7f1c207e04a1744704cd | |
parent | 738cb42a14481aa9ae58704f6bee951308212d7e [diff] [blame] |
bpo-36452: dictiter: track maximum iteration count (GH-12596)
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 @@ 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);