diff options
| author | INADA Naoki <methane@users.noreply.github.com> | 2017-09-04 12:31:41 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-09-04 12:31:41 +0900 |
| commit | 4cde4bdcc86cb08ee3847500a172cc24eba37ffe (patch) | |
| tree | cfc4c00f39f0cc6e9fec1e9756cf81c059ff9d6a /Modules/_json.c | |
| parent | 990b2d043cdfaafc3378550f7d27259410a6b918 (diff) | |
| download | cpython-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.c | 6 |
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); } |
