diff options
author | INADA Naoki <methane@users.noreply.github.com> | 2017-08-24 05:55:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-24 05:55:17 (GMT) |
commit | a6296d34a478b4f697ea9db798146195075d496c (patch) | |
tree | 6a26d56297f7d85dd6a8f18bca96e0c4ffb60802 /Objects/dictobject.c | |
parent | bf9075a0c55186d2f34df63e6c8512dd6414ff4b (diff) | |
download | cpython-a6296d34a478b4f697ea9db798146195075d496c.zip cpython-a6296d34a478b4f697ea9db798146195075d496c.tar.gz cpython-a6296d34a478b4f697ea9db798146195075d496c.tar.bz2 |
bpo-31095: fix potential crash during GC (GH-2974)
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r-- | Objects/dictobject.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c index e395f4d..f055170 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -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); } |