From e49f9f584612700f322916d03b6bcc91ddb136ec Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 3 Mar 2024 20:27:53 +0100 Subject: fix use after free --- src/main_windows.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/main_windows.cpp') diff --git a/src/main_windows.cpp b/src/main_windows.cpp index 9930b46..d985416 100644 --- a/src/main_windows.cpp +++ b/src/main_windows.cpp @@ -317,13 +317,13 @@ void ts_platform_list_files_block(ts_search_result* result, wchar_t* start_dir) wcscat(complete_file_path, L"\\"); wcscat(complete_file_path, name); - ts_found_file f; - f.path = (utf8_int8_t*)malloc(MAX_INPUT_LENGTH); - f.match_count = 0; - WideCharToMultiByte(CP_UTF8,0,complete_file_path,-1,(LPSTR)f.path,MAX_INPUT_LENGTH, NULL, NULL); + ts_found_file* f = (ts_found_file*)malloc(MAX_INPUT_LENGTH); + f->path = (utf8_int8_t*)malloc(MAX_INPUT_LENGTH); + f->match_count = 0; + WideCharToMultiByte(CP_UTF8,0,complete_file_path,-1,(LPSTR)f->path,MAX_INPUT_LENGTH, NULL, NULL); ts_mutex_lock(&result->files.mutex); - ts_array_push_size(&result->files, &f, sizeof(ts_found_file)); + ts_array_push_size(&result->files, &f, sizeof(ts_found_file*)); ts_mutex_unlock(&result->files.mutex); } -- cgit v1.2.3-70-g09d2