summaryrefslogtreecommitdiff
path: root/Objects/setobject.c
diff options
context:
space:
mode:
authorINADA Naoki <methane@users.noreply.github.com>2017-09-04 12:31:09 +0900
committerGitHub <noreply@github.com>2017-09-04 12:31:09 +0900
commit2eea952b1b9ebbc2d94fd3faca1536c6b4963725 (patch)
tree5262bce350c874f5397b8ad2ca2a6671cb4dd9d6 /Objects/setobject.c
parent7d8282d25d4900dd3367daf28bb393be7f276729 (diff)
downloadcpython-git-2eea952b1b9ebbc2d94fd3faca1536c6b4963725.tar.gz
bpo-31095: fix potential crash during GC (GH-3195)
(cherry picked from commit a6296d34a478b4f697ea9db798146195075d496c)
Diffstat (limited to 'Objects/setobject.c')
-rw-r--r--Objects/setobject.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c
index c1bc1e1234..24272b4d14 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -556,6 +556,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)
@@ -812,6 +813,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);
}