From f028aa407699d46b677ecc3cd72933c536aec98a Mon Sep 17 00:00:00 2001 From: Hajo Kirchhoff Date: Tue, 10 Aug 2021 13:26:02 +0200 Subject: [PATCH] -fix: issue #239 exec_file does not close the FILE handle. Note: Using FILE* is a bad choice here because of possible exceptions, but Py_RunFile is a C function. This fix works, because Py_RunFile - as a C function - does not throw exceptions. --- src/exec.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/exec.cpp b/src/exec.cpp index df197169..7488da1f 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -129,6 +129,7 @@ object BOOST_PYTHON_DECL exec_file(char const *filename, object global, object l f, Py_file_input, global.ptr(), local.ptr()); + fclose(fs); if (!result) throw_error_already_set(); return object(detail::new_reference(result)); }