summaryrefslogtreecommitdiff
path: root/Modules/_json.c
diff options
context:
space:
mode:
authorINADA Naoki <methane@users.noreply.github.com>2017-09-04 12:31:41 +0900
committerGitHub <noreply@github.com>2017-09-04 12:31:41 +0900
commit4cde4bdcc86cb08ee3847500a172cc24eba37ffe (patch)
treecfc4c00f39f0cc6e9fec1e9756cf81c059ff9d6a /Modules/_json.c
parent990b2d043cdfaafc3378550f7d27259410a6b918 (diff)
downloadcpython-git-4cde4bdcc86cb08ee3847500a172cc24eba37ffe.tar.gz
bpo-31095: Fix potential crash during GC (GH-3197)
(cherry picked from commit a6296d34a478b4f697ea9db798146195075d496c)
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 42c93aba1e..be1e079696 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -840,7 +840,8 @@ py_encode_basestring_ascii(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);
}
@@ -2298,7 +2299,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);
}