bpo-38555: Fix an undefined behavior. (GH-16883)
(cherry picked from commit 2e3d873d3b
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
e113b5c3e7
commit
c5d3ea89ee
|
@ -3840,22 +3840,21 @@ dictreviter_iternext(dictiterobject *di)
|
|||
PyDictKeysObject *k = d->ma_keys;
|
||||
PyObject *key, *value, *result;
|
||||
|
||||
if (i < 0) {
|
||||
goto fail;
|
||||
}
|
||||
if (d->ma_values) {
|
||||
if (i < 0) {
|
||||
goto fail;
|
||||
}
|
||||
key = DK_ENTRIES(k)[i].me_key;
|
||||
value = d->ma_values[i];
|
||||
assert (value != NULL);
|
||||
}
|
||||
else {
|
||||
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--;
|
||||
i--;
|
||||
}
|
||||
if (i < 0) {
|
||||
goto fail;
|
||||
}
|
||||
key = entry_ptr->me_key;
|
||||
value = entry_ptr->me_value;
|
||||
|
|
Loading…
Reference in New Issue