summaryrefslogtreecommitdiff
path: root/Modules/_io
diff options
context:
space:
mode:
authorINADA Naoki <methane@users.noreply.github.com>2017-08-24 14:55:17 +0900
committerGitHub <noreply@github.com>2017-08-24 14:55:17 +0900
commita6296d34a478b4f697ea9db798146195075d496c (patch)
tree6a26d56297f7d85dd6a8f18bca96e0c4ffb60802 /Modules/_io
parentbf9075a0c55186d2f34df63e6c8512dd6414ff4b (diff)
downloadcpython-git-a6296d34a478b4f697ea9db798146195075d496c.tar.gz
bpo-31095: fix potential crash during GC (GH-2974)
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/bytesio.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c
index 42c7f7933e..ba33f8c50d 100644
--- a/Modules/_io/bytesio.c
+++ b/Modules/_io/bytesio.c
@@ -1084,6 +1084,8 @@ bytesiobuf_traverse(bytesiobuf *self, visitproc visit, void *arg)
static void
bytesiobuf_dealloc(bytesiobuf *self)
{
+ /* bpo-31095: UnTrack is needed before calling any callbacks */
+ PyObject_GC_UnTrack(self);
Py_CLEAR(self->source);
Py_TYPE(self)->tp_free(self);
}