summaryrefslogtreecommitdiffstats
path: root/Modules/_collectionsmodule.c
diff options
context:
space:
mode:
authorINADA Naoki <methane@users.noreply.github.com>2017-08-24 05:55:17 (GMT)
committerGitHub <noreply@github.com>2017-08-24 05:55:17 (GMT)
commita6296d34a478b4f697ea9db798146195075d496c (patch)
tree6a26d56297f7d85dd6a8f18bca96e0c4ffb60802 /Modules/_collectionsmodule.c
parentbf9075a0c55186d2f34df63e6c8512dd6414ff4b (diff)
downloadcpython-a6296d34a478b4f697ea9db798146195075d496c.zip
cpython-a6296d34a478b4f697ea9db798146195075d496c.tar.gz
cpython-a6296d34a478b4f697ea9db798146195075d496c.tar.bz2
bpo-31095: fix potential crash during GC (GH-2974)
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r--Modules/_collectionsmodule.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index aa582ed..adbe789 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -1717,6 +1717,8 @@ dequeiter_traverse(dequeiterobject *dio, visitproc visit, void *arg)
static void
dequeiter_dealloc(dequeiterobject *dio)
{
+ /* bpo-31095: UnTrack is needed before calling any callbacks */
+ PyObject_GC_UnTrack(dio);
Py_XDECREF(dio->deque);
PyObject_GC_Del(dio);
}
@@ -2097,6 +2099,8 @@ static PyMemberDef defdict_members[] = {
static void
defdict_dealloc(defdictobject *dd)
{
+ /* bpo-31095: UnTrack is needed before calling any callbacks */
+ PyObject_GC_UnTrack(dd);
Py_CLEAR(dd->default_factory);
PyDict_Type.tp_dealloc((PyObject *)dd);
}