Mercurial > cpython-lru_cache-weakref
diff Modules/_io/stringio.c @ 55395:d747d52f9a66
Issue #6242: Fix deallocator of io.StringIO and io.BytesIO.
| author | Alexandre Vassalotti <alexandre@peadrop.com> |
|---|---|
| date | Wed, 22 Jul 2009 02:24:49 +0000 |
| parents | 4658fcaafc73 |
| children | d682ca888e27 |
line wrap: on
line diff
--- a/Modules/_io/stringio.c Wed Jul 22 00:30:24 2009 +0000 +++ b/Modules/_io/stringio.c Wed Jul 22 02:24:49 2009 +0000 @@ -509,11 +509,15 @@ stringio_dealloc(stringio *self) { _PyObject_GC_UNTRACK(self); + self->ok = 0; + if (self->buf) { + PyMem_Free(self->buf); + self->buf = NULL; + } Py_CLEAR(self->readnl); Py_CLEAR(self->writenl); Py_CLEAR(self->decoder); - if (self->buf) - PyMem_Free(self->buf); + Py_CLEAR(self->dict); if (self->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) self); Py_TYPE(self)->tp_free(self);
