diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-11-06 21:28:31 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-11-06 21:28:31 +0200 |
commit | c9733f38bd45e2d825a4ca85d178ebca94877937 (patch) | |
tree | 70ade84eb8671bec4ef48427476529f862c8a44d | |
parent | ef4015d1d997c234d2bb604b4d858e04cdbceeb3 (diff) | |
download | simplejson-bpo-31095.tar.gz |
bpo-31095: fix potential crash during GCbpo-31095
Original patch by INADA Naoki.
-rw-r--r-- | simplejson/_speedups.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/simplejson/_speedups.c b/simplejson/_speedups.c index 7b46d8a..ed8e611 100644 --- a/simplejson/_speedups.c +++ b/simplejson/_speedups.c @@ -1355,7 +1355,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); } @@ -3205,7 +3206,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); } |