summaryrefslogtreecommitdiffstats
path: root/Modules/_json.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/_json.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/_json.c')
-rw-r--r--Modules/_json.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/_json.c b/Modules/_json.c
index 6cc31c6..54fc90c 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -655,7 +655,8 @@ py_encode_basestring(PyObject* self UNUSED, PyObject *pystr)
static void
scanner_dealloc(PyObject *self)
{
- /* Deallocate scanner object */
+ /* bpo-31095: UnTrack is needed before calling any callbacks */
+ PyObject_GC_UnTrack(self);
scanner_clear(self);
Py_TYPE(self)->tp_free(self);
}
@@ -1778,7 +1779,8 @@ bail:
static void
encoder_dealloc(PyObject *self)
{
- /* Deallocate Encoder */
+ /* bpo-31095: UnTrack is needed before calling any callbacks */
+ PyObject_GC_UnTrack(self);
encoder_clear(self);
Py_TYPE(self)->tp_free(self);
}