https://github.com/python/cpython/commit/92cebaa4911786683e87841bf7788351e7595ac2
commit: 92cebaa4911786683e87841bf7788351e7595ac2
branch: main
author: Carson Radtke <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2024-06-16T17:51:52Z
summary:
gh-120568: fix file leak in PyUnstable_CopyPerfMapFile (#120569)
files:
M Python/sysmodule.c
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 00aa95531026b5..3bb7b4d59b94e2 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -2509,16 +2509,16 @@ PyAPI_FUNC(void) PyUnstable_PerfMapState_Fini(void) {
PyAPI_FUNC(int) PyUnstable_CopyPerfMapFile(const char* parent_filename) {
#ifndef MS_WINDOWS
- FILE* from = fopen(parent_filename, "r");
- if (!from) {
- return -1;
- }
if (perf_map_state.perf_map == NULL) {
int ret = PyUnstable_PerfMapState_Init();
if (ret != 0) {
return ret;
}
}
+ FILE* from = fopen(parent_filename, "r");
+ if (!from) {
+ return -1;
+ }
char buf[4096];
PyThread_acquire_lock(perf_map_state.map_lock, 1);
int fflush_result = 0, result = 0;
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]