summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-05-17 19:56:59 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-05-17 19:56:59 (GMT)
commit83137c2e16ab34ecfa9695ae976b2b36fda2a17a (patch)
treebde315c150480fc78cba19af523acb1207481d9c /Objects
parentaf87f9f09f264d64ca564efd6818a1d0d7248a31 (diff)
downloadcpython-83137c2e16ab34ecfa9695ae976b2b36fda2a17a.zip
cpython-83137c2e16ab34ecfa9695ae976b2b36fda2a17a.tar.gz
cpython-83137c2e16ab34ecfa9695ae976b2b36fda2a17a.tar.bz2
Issue #7079: Fix a possible crash when closing a file object while using
it from another thread. Patch by Daniel Stutzbach.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/fileobject.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 6b95a0c..d83c054 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -649,8 +649,10 @@ static PyObject *
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;
}