Skip to content

Commit

Permalink
bpo-31095: fix potential crash during GC (#187)
Browse files Browse the repository at this point in the history
Original patch by INADA Naoki.
  • Loading branch information
serhiy-storchaka committed Nov 6, 2017
1 parent 113039a commit 138a2ff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions simplejson/_speedups.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -3208,7 +3209,8 @@ encoder_listencode_list(PyEncoderObject *s, JSON_Accu *rval, PyObject *seq, Py_s
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);
}
Expand Down

0 comments on commit 138a2ff

Please sign in to comment.