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 | |
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')
-rw-r--r-- | Objects/dictobject.c | 6 | ||||
-rw-r--r-- | Objects/setobject.c | 3 |
2 files changed, 9 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); } diff --git a/Objects/setobject.c b/Objects/setobject.c index 2347b9d..5c61bc7 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -553,6 +553,7 @@ set_dealloc(PySetObject *so) setentry *entry; Py_ssize_t used = so->used; + /* bpo-31095: UnTrack is needed before calling any callbacks */ PyObject_GC_UnTrack(so); Py_TRASHCAN_SAFE_BEGIN(so) if (so->weakreflist != NULL) @@ -809,6 +810,8 @@ typedef struct { static void setiter_dealloc(setiterobject *si) { + /* bpo-31095: UnTrack is needed before calling any callbacks */ + _PyObject_GC_UNTRACK(si); Py_XDECREF(si->si_set); PyObject_GC_Del(si); } |