mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
Fix IMalloc* leak in Win32 ShowDirectoryDialog
This commit is contained in:
@@ -179,9 +179,8 @@ namespace OpenRCT2::Ui
|
||||
{
|
||||
std::string result;
|
||||
|
||||
// Initialize COM and get a pointer to the shell memory allocator
|
||||
LPMALLOC lpMalloc;
|
||||
if (SUCCEEDED(CoInitializeEx(0, COINIT_APARTMENTTHREADED)) && SUCCEEDED(SHGetMalloc(&lpMalloc)))
|
||||
// Initialize COM
|
||||
if (SUCCEEDED(CoInitializeEx(0, COINIT_APARTMENTTHREADED)))
|
||||
{
|
||||
std::wstring titleW = String::ToWideChar(title);
|
||||
BROWSEINFOW bi = {};
|
||||
@@ -194,12 +193,13 @@ namespace OpenRCT2::Ui
|
||||
result = String::ToUtf8(SHGetPathFromIDListLongPath(pidl));
|
||||
}
|
||||
CoTaskMemFree(pidl);
|
||||
|
||||
CoUninitialize();
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error("Error opening directory browse window");
|
||||
}
|
||||
CoUninitialize();
|
||||
|
||||
// SHBrowseForFolderW might minimize the main window,
|
||||
// so make sure that it's visible again.
|
||||
|
||||
Reference in New Issue
Block a user