summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-11-06 21:28:31 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2017-11-06 21:28:31 +0200
commitc9733f38bd45e2d825a4ca85d178ebca94877937 (patch)
tree70ade84eb8671bec4ef48427476529f862c8a44d
parentef4015d1d997c234d2bb604b4d858e04cdbceeb3 (diff)
downloadsimplejson-bpo-31095.tar.gz
bpo-31095: fix potential crash during GCbpo-31095
Original patch by INADA Naoki.
-rw-r--r--simplejson/_speedups.c6
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);
}