Correctly compare the hint against the keys in _PyDict_GetItemHint (GH-22960)

This commit is contained in:
Pablo Galindo 2020-10-25 06:08:17 +00:00 committed by GitHub
parent 4a9c637938
commit 492d513ccb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1448,7 +1448,7 @@ _PyDict_GetItemHint(PyDictObject *mp, PyObject *key,
assert(PyDict_CheckExact((PyObject*)mp));
assert(PyUnicode_CheckExact(key));
if (hint >= 0 && hint < _PyDict_KeysSize(mp->ma_keys)) {
if (hint >= 0 && hint < mp->ma_keys->dk_nentries) {
PyObject *res = NULL;
PyDictKeyEntry *ep = DK_ENTRIES(mp->ma_keys) + (size_t)hint;