diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-11-06 23:12:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-06 23:12:35 +0200 |
commit | 138a2ff3f6db37468f3c7509f69c984792fd49a0 (patch) | |
tree | a690cf99d1c312c504c098f72191e0a52b2d40ba /simplejson/_speedups.c | |
parent | 113039ae96e670b8f7441d5b1d2c40d9b0b75f56 (diff) | |
download | simplejson-138a2ff3f6db37468f3c7509f69c984792fd49a0.tar.gz |
bpo-31095: fix potential crash during GC (#187)
Original patch by INADA Naoki.
Diffstat (limited to 'simplejson/_speedups.c')
-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 e4620b5..bfd053a 100644 --- a/simplejson/_speedups.c +++ b/simplejson/_speedups.c @@ -1358,7 +1358,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); } @@ -3208,7 +3209,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); } |