Commit cab0f577 authored by Antoine Pitrou's avatar Antoine Pitrou

Issue #14505: Fix file descriptor leak when deallocating file objects created...

Issue #14505: Fix file descriptor leak when deallocating file objects created with PyFile_FromString().
parent 88ba5b33
...@@ -9,6 +9,9 @@ What's New in Python 2.7.4 ...@@ -9,6 +9,9 @@ What's New in Python 2.7.4
Core and Builtins 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() - Issue #14474: Save and restore exception state in thread.start_new_thread()
while writing error message if the thread leaves a unhandled exception. while writing error message if the thread leaves a unhandled exception.
......
...@@ -493,9 +493,10 @@ PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *)) ...@@ -493,9 +493,10 @@ PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *))
PyObject * PyObject *
PyFile_FromString(char *name, char *mode) PyFile_FromString(char *name, char *mode)
{ {
extern int fclose(FILE *);
PyFileObject *f; PyFileObject *f;
f = (PyFileObject *)PyFile_FromFile((FILE *)NULL, name, mode, NULL); f = (PyFileObject *)PyFile_FromFile((FILE *)NULL, name, mode, fclose);
if (f != NULL) { if (f != NULL) {
if (open_the_file(f, name, mode) == NULL) { if (open_the_file(f, name, mode) == NULL) {
Py_DECREF(f); Py_DECREF(f);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment