Skip to content

Commit a0ed9e2

Browse files
committed
Fix off by one error
1 parent e858ea1 commit a0ed9e2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Python/ceval.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3517,6 +3517,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
35173517
DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR);
35183518
PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict;
35193519
DEOPT_IF(dict->ma_keys->dk_version != cache1->dk_version_or_hint, LOAD_ATTR);
3520+
assert(dict->ma_keys->dk_kind == DICT_KEYS_UNICODE);
35203521
assert(cache0->index < dict->ma_keys->dk_nentries);
35213522
PyDictKeyEntry *ep = DK_ENTRIES(dict->ma_keys) + cache0->index;
35223523
res = ep->me_value;
@@ -3544,7 +3545,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
35443545
assert(PyDict_CheckExact((PyObject *)dict));
35453546
PyObject *name = GETITEM(names, cache0->original_oparg);
35463547
uint32_t hint = cache1->dk_version_or_hint;
3547-
DEOPT_IF(hint > dict->ma_keys->dk_nentries, LOAD_ATTR);
3548+
DEOPT_IF(hint >= dict->ma_keys->dk_nentries, LOAD_ATTR);
35483549
PyDictKeyEntry *ep = DK_ENTRIES(dict->ma_keys) + hint;
35493550
DEOPT_IF(ep->me_key != name, LOAD_ATTR);
35503551
res = ep->me_value;

0 commit comments

Comments
 (0)