diff options
author | INADA Naoki <methane@users.noreply.github.com> | 2017-09-04 03:31:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-04 03:31:09 (GMT) |
commit | 2eea952b1b9ebbc2d94fd3faca1536c6b4963725 (patch) | |
tree | 5262bce350c874f5397b8ad2ca2a6671cb4dd9d6 /Modules/_json.c | |
parent | 7d8282d25d4900dd3367daf28bb393be7f276729 (diff) | |
download | cpython-2eea952b1b9ebbc2d94fd3faca1536c6b4963725.zip cpython-2eea952b1b9ebbc2d94fd3faca1536c6b4963725.tar.gz cpython-2eea952b1b9ebbc2d94fd3faca1536c6b4963725.tar.bz2 |
bpo-31095: fix potential crash during GC (GH-3195)
(cherry picked from commit a6296d34a478b4f697ea9db798146195075d496c)
Diffstat (limited to 'Modules/_json.c')
-rw-r--r-- | Modules/_json.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/_json.c b/Modules/_json.c index 1be4c17..59376a7 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); } @@ -1793,7 +1794,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); } |