Mercurial > cpython-lru_cache-weakref
diff Objects/fileobject.c @ 61677:f0fcd69187cd legacy-trunk
Issue #7079: Fix a possible crash when closing a file object while using
it from another thread. Patch by Daniel Stutzbach.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Mon, 17 May 2010 19:56:59 +0000 |
| parents | fd25030223b0 |
| children | e60ef17561dc |
line wrap: on
line diff
--- a/Objects/fileobject.c Mon May 17 13:35:09 2010 +0000 +++ b/Objects/fileobject.c Mon May 17 19:56:59 2010 +0000 @@ -649,8 +649,10 @@ file_close(PyFileObject *f) { PyObject *sts = close_the_file(f); - PyMem_Free(f->f_setbuf); - f->f_setbuf = NULL; + if (sts) { + PyMem_Free(f->f_setbuf); + f->f_setbuf = NULL; + } return sts; }
