mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-34042: Fix dict.copy() to maintain correct total refcount (GH-8119)
This commit is contained in:
parent
dc9bc54899
commit
0b75228700
2 changed files with 9 additions and 0 deletions
|
@ -656,6 +656,13 @@ clone_combined_dict(PyDictObject *orig)
|
|||
/* Maintain tracking. */
|
||||
_PyObject_GC_TRACK(new);
|
||||
}
|
||||
|
||||
/* Since we copied the keys table we now have an extra reference
|
||||
in the system. Manually call _Py_INC_REFTOTAL to signal that
|
||||
we have it now; calling DK_INCREF would be an error as
|
||||
keys->dk_refcnt is already set to 1 (after memcpy). */
|
||||
_Py_INC_REFTOTAL;
|
||||
|
||||
return (PyObject *)new;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue