Commit 2e3d873d authored by Serhiy Storchaka's avatar Serhiy Storchaka Committed by GitHub

bpo-38555: Fix an undefined behavior. (GH-16883)

parent d34ac305
...@@ -3830,22 +3830,21 @@ dictreviter_iternext(dictiterobject *di) ...@@ -3830,22 +3830,21 @@ dictreviter_iternext(dictiterobject *di)
PyDictKeysObject *k = d->ma_keys; PyDictKeysObject *k = d->ma_keys;
PyObject *key, *value, *result; PyObject *key, *value, *result;
if (i < 0) {
goto fail;
}
if (d->ma_values) { if (d->ma_values) {
if (i < 0) {
goto fail;
}
key = DK_ENTRIES(k)[i].me_key; key = DK_ENTRIES(k)[i].me_key;
value = d->ma_values[i]; value = d->ma_values[i];
assert (value != NULL); assert (value != NULL);
} }
else { else {
PyDictKeyEntry *entry_ptr = &DK_ENTRIES(k)[i]; PyDictKeyEntry *entry_ptr = &DK_ENTRIES(k)[i];
while (i >= 0 && entry_ptr->me_value == NULL) { while (entry_ptr->me_value == NULL) {
if (--i < 0) {
goto fail;
}
entry_ptr--; entry_ptr--;
i--;
}
if (i < 0) {
goto fail;
} }
key = entry_ptr->me_key; key = entry_ptr->me_key;
value = entry_ptr->me_value; value = entry_ptr->me_value;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment