mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-31095: fix potential crash during GC (GH-2974)
This commit is contained in:
parent
bf9075a0c5
commit
a6296d34a4
14 changed files with 60 additions and 13 deletions
|
@ -1847,6 +1847,8 @@ dict_dealloc(PyDictObject *mp)
|
|||
PyObject **values = mp->ma_values;
|
||||
PyDictKeysObject *keys = mp->ma_keys;
|
||||
Py_ssize_t i, n;
|
||||
|
||||
/* bpo-31095: UnTrack is needed before calling any callbacks */
|
||||
PyObject_GC_UnTrack(mp);
|
||||
Py_TRASHCAN_SAFE_BEGIN(mp)
|
||||
if (values != NULL) {
|
||||
|
@ -3270,6 +3272,8 @@ dictiter_new(PyDictObject *dict, PyTypeObject *itertype)
|
|||
static void
|
||||
dictiter_dealloc(dictiterobject *di)
|
||||
{
|
||||
/* bpo-31095: UnTrack is needed before calling any callbacks */
|
||||
_PyObject_GC_UNTRACK(di);
|
||||
Py_XDECREF(di->di_dict);
|
||||
Py_XDECREF(di->di_result);
|
||||
PyObject_GC_Del(di);
|
||||
|
@ -3629,6 +3633,8 @@ dictiter_reduce(dictiterobject *di)
|
|||
static void
|
||||
dictview_dealloc(_PyDictViewObject *dv)
|
||||
{
|
||||
/* bpo-31095: UnTrack is needed before calling any callbacks */
|
||||
_PyObject_GC_UNTRACK(dv);
|
||||
Py_XDECREF(dv->dv_dict);
|
||||
PyObject_GC_Del(dv);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue