mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
gh-120568: fix file leak in PyUnstable_CopyPerfMapFile (#120569)
This commit is contained in:
parent
b337aefd3e
commit
92cebaa491
1 changed files with 4 additions and 4 deletions
|
@ -2509,16 +2509,16 @@ PyAPI_FUNC(void) PyUnstable_PerfMapState_Fini(void) {
|
||||||
|
|
||||||
PyAPI_FUNC(int) PyUnstable_CopyPerfMapFile(const char* parent_filename) {
|
PyAPI_FUNC(int) PyUnstable_CopyPerfMapFile(const char* parent_filename) {
|
||||||
#ifndef MS_WINDOWS
|
#ifndef MS_WINDOWS
|
||||||
FILE* from = fopen(parent_filename, "r");
|
|
||||||
if (!from) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (perf_map_state.perf_map == NULL) {
|
if (perf_map_state.perf_map == NULL) {
|
||||||
int ret = PyUnstable_PerfMapState_Init();
|
int ret = PyUnstable_PerfMapState_Init();
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FILE* from = fopen(parent_filename, "r");
|
||||||
|
if (!from) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
PyThread_acquire_lock(perf_map_state.map_lock, 1);
|
PyThread_acquire_lock(perf_map_state.map_lock, 1);
|
||||||
int fflush_result = 0, result = 0;
|
int fflush_result = 0, result = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue