[Python-checkins] gh-98872: Fix a possible resource leak in Python 3.11.0 (GH-99047)

miss-islington webhook-mailer at python.org
Thu Nov 24 04:04:25 EST 2022


https://github.com/python/cpython/commit/4e5f2db6f228d45a655cf22fd587792d56116145
commit: 4e5f2db6f228d45a655cf22fd587792d56116145
branch: main
author: SQLPATCH <95843853+SQLPATCH at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-11-24T01:04:19-08:00
summary:

gh-98872: Fix a possible resource leak in Python 3.11.0 (GH-99047)



Issue: #98872

Automerge-Triggered-By: GH:kumaraditya303

files:
A Misc/NEWS.d/next/Build/2022-11-03-08-10-49.gh-issue-98872.gdsR8X.rst
M Programs/_freeze_module.c

diff --git a/Misc/NEWS.d/next/Build/2022-11-03-08-10-49.gh-issue-98872.gdsR8X.rst b/Misc/NEWS.d/next/Build/2022-11-03-08-10-49.gh-issue-98872.gdsR8X.rst
new file mode 100644
index 000000000000..ad4dc496ee0e
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2022-11-03-08-10-49.gh-issue-98872.gdsR8X.rst
@@ -0,0 +1 @@
+Fix a possible fd leak in ``Programs/_freeze_module.c`` introduced in Python 3.11.
diff --git a/Programs/_freeze_module.c b/Programs/_freeze_module.c
index d6d737d48d60..9e2169f32e92 100644
--- a/Programs/_freeze_module.c
+++ b/Programs/_freeze_module.c
@@ -194,6 +194,7 @@ write_frozen(const char *outpath, const char *inpath, const char *name,
 
     if (ferror(outfile)) {
         fprintf(stderr, "error when writing to '%s'\n", outpath);
+        fclose(outfile);
         return -1;
     }
     fclose(outfile);



More information about the Python-checkins mailing list