diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2012-04-05 12:07:52 (GMT) |
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-04-05 12:07:52 (GMT) |
| commit | 02a380105d4cd31219d2dc468f277688973ec2bd (patch) | |
| tree | 17252972b130ce680cd502104cf7b5938b35c610 | |
| parent | b45c5e2d0ee566eba9400ac6b2b3e44ddbffdc58 (diff) | |
| download | cpython-02a380105d4cd31219d2dc468f277688973ec2bd.zip cpython-02a380105d4cd31219d2dc468f277688973ec2bd.tar.gz cpython-02a380105d4cd31219d2dc468f277688973ec2bd.tar.bz2 | |
Issue #14505: Fix file descriptor leak when deallocating file objects created with PyFile_FromString().
| -rw-r--r-- | Misc/NEWS | 3 | ||||
| -rw-r--r-- | Objects/fileobject.c | 3 |
2 files changed, 5 insertions, 1 deletions
@@ -9,6 +9,9 @@ What's New in Python 2.7.4 Core and Builtins ----------------- +- Issue #14505: Fix file descriptor leak when deallocating file objects + created with PyFile_FromString(). + - Issue #14474: Save and restore exception state in thread.start_new_thread() while writing error message if the thread leaves a unhandled exception. diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 050e239..1d8142e 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -493,9 +493,10 @@ PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *)) PyObject * PyFile_FromString(char *name, char *mode) { + extern int fclose(FILE *); PyFileObject *f; - f = (PyFileObject *)PyFile_FromFile((FILE *)NULL, name, mode, NULL); + f = (PyFileObject *)PyFile_FromFile((FILE *)NULL, name, mode, fclose); if (f != NULL) { if (open_the_file(f, name, mode) == NULL) { Py_DECREF(f); |
