diff options
author | Andrew MacIntyre <andymac@bullseye.apana.org.au> | 2004-04-04 07:01:35 (GMT) |
---|---|---|
committer | Andrew MacIntyre <andymac@bullseye.apana.org.au> | 2004-04-04 07:01:35 (GMT) |
commit | 4e10ed3b86cf08211ef0c9c5408799195c2c1881 (patch) | |
tree | aa4ba6c69b025b087a79eea302c9ed6d0ccb6ca8 /Objects/fileobject.c | |
parent | ba813e20892157befdefa60df88c19bae52fc766 (diff) | |
download | cpython-4e10ed3b86cf08211ef0c9c5408799195c2c1881.zip cpython-4e10ed3b86cf08211ef0c9c5408799195c2c1881.tar.gz cpython-4e10ed3b86cf08211ef0c9c5408799195c2c1881.tar.bz2 |
If a file is opened with an explicit buffer size >= 1, repeated
close() calls would attempt to free() the buffer already free()ed on
the first close(). [bug introduced with patch #788249]
Making sure that the buffer is free()ed in file object deallocation is
a belt-n-braces bit of insurance against a memory leak.
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r-- | Objects/fileobject.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c index c973366..6b7e01b 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -312,6 +312,7 @@ file_dealloc(PyFileObject *f) (*f->f_close)(f->f_fp); Py_END_ALLOW_THREADS } + PyMem_Free(f->f_setbuf); Py_XDECREF(f->f_name); Py_XDECREF(f->f_mode); Py_XDECREF(f->f_encoding); @@ -358,6 +359,7 @@ file_close(PyFileObject *f) f->f_fp = NULL; } PyMem_Free(f->f_setbuf); + f->f_setbuf = NULL; if (sts == EOF) return PyErr_SetFromErrno(PyExc_IOError); if (sts != 0) |