[SHELL32] CoUninitialize only if CoInitialize* is successful

Technically CoUninitialize should be called only if CoInitializeEx succeeded (including S_FALSE).
CORE-1419
This commit is contained in:
Katayama Hirofumi MZ 2020-09-28 20:13:28 +09:00
parent 467feb9996
commit a822eadce6

View file

@ -29,6 +29,7 @@ typedef struct
LPCWSTR lpstrTitle;
LPCWSTR lpstrDescription;
UINT uFlags;
BOOL bCoInited;
} RUNFILEDLGPARAMS;
typedef BOOL (WINAPI * LPFNOFN) (OPENFILENAMEW *);
@ -549,14 +550,17 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
hwndEdit = ComboInfo.hwndItem;
ASSERT(::IsWindow(hwndEdit));
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); // SHAutoComplete needs co init
// SHAutoComplete needs co init
prfdp->bCoInited = SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
SHAutoComplete(hwndEdit, SHACF_FILESYSTEM | SHACF_FILESYS_ONLY | SHACF_URLALL);
SetFocus(hwndCombo);
return TRUE;
case WM_DESTROY:
CoUninitialize();
if (prfdp->bCoInited)
CoUninitialize();
break;
case WM_COMMAND: