diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-03 20:27:53 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-03 20:27:53 +0100 |
| commit | e49f9f584612700f322916d03b6bcc91ddb136ec (patch) | |
| tree | 1859299fc87eb902516ebc5dbb2320f3d54ecd18 /src/main_windows.cpp | |
| parent | 7e0a7cea406d4dd4733dfa834ac7c41ce848e658 (diff) | |
fix use after free
Diffstat (limited to 'src/main_windows.cpp')
| -rw-r--r-- | src/main_windows.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
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); } |
