diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-10-24 11:59:41 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-10-24 11:59:41 (GMT) |
commit | f98a267be374508c04faa4200f552804399faed8 (patch) | |
tree | 9bc0e9ada7b01b26211123037c18367aff7b978e /Modules/_io/stringio.c | |
parent | 5f029ce66420c3259a6655dc52769edf494c5248 (diff) | |
download | cpython-f98a267be374508c04faa4200f552804399faed8.zip cpython-f98a267be374508c04faa4200f552804399faed8.tar.gz cpython-f98a267be374508c04faa4200f552804399faed8.tar.bz2 |
Manual py3k backport: [svn r74155] Issue #6242: Fix deallocator of io.StringIO and io.BytesIO
Diffstat (limited to 'Modules/_io/stringio.c')
-rw-r--r-- | Modules/_io/stringio.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c index ddb081d..95180a9 100644 --- a/Modules/_io/stringio.c +++ b/Modules/_io/stringio.c @@ -515,11 +515,15 @@ static void 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); |