diff options
author | Carson Radtke <carsonRadtke@users.noreply.github.com> | 2024-06-16 17:51:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-16 17:51:52 (GMT) |
commit | 92cebaa4911786683e87841bf7788351e7595ac2 (patch) | |
tree | bf0d2a1d8a7c94f44f27fb43ff240335cb030856 /Python | |
parent | b337aefd3e44f5c8e38cd282273359d07cce6126 (diff) | |
download | cpython-92cebaa4911786683e87841bf7788351e7595ac2.zip cpython-92cebaa4911786683e87841bf7788351e7595ac2.tar.gz cpython-92cebaa4911786683e87841bf7788351e7595ac2.tar.bz2 |
gh-120568: fix file leak in PyUnstable_CopyPerfMapFile (#120569)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/sysmodule.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 00aa955..3bb7b4d 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; |