Skip to content

Commit

Permalink
dict: Fix refleak (GH-31650)
Browse files Browse the repository at this point in the history
  • Loading branch information
methane committed Mar 3, 2022
1 parent 59e1ce9 commit 3241cba
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Objects/dictobject.c
Expand Up @@ -1523,12 +1523,16 @@ dictresize(PyDictObject *mp, uint8_t log2_newsize, int unicode)

// We can not use free_keys_object here because key's reference
// are moved already.
if (oldkeys != Py_EMPTY_KEYS) {
assert(oldkeys->dk_kind != DICT_KEYS_SPLIT);
assert(oldkeys->dk_refcnt == 1);
#ifdef Py_REF_DEBUG
_Py_RefTotal--;
_Py_RefTotal--;
#endif
if (oldkeys == Py_EMPTY_KEYS) {
oldkeys->dk_refcnt--;
assert(oldkeys->dk_refcnt > 0);
}
else {
assert(oldkeys->dk_kind != DICT_KEYS_SPLIT);
assert(oldkeys->dk_refcnt == 1);
#if PyDict_MAXFREELIST > 0
struct _Py_dict_state *state = get_dict_state();
#ifdef Py_DEBUG
Expand Down

0 comments on commit 3241cba

Please sign in to comment.