txt: free already loaded libraries on LoadLibraryW() failure

This fixes a future "Resource leak" cppcheck error.
This commit is contained in:
Fabian Greffrath 2019-01-28 09:34:12 +01:00
parent 173300a37b
commit 59f737ad1b

View file

@ -175,14 +175,21 @@ static BOOL (*MySHGetPathFromIDList)(LPITEMIDLIST, LPTSTR) = NULL;
static int LoadDLLs(void)
{
HMODULE comdlg32 = LoadLibraryW(L"comdlg32.dll");
HMODULE shell32 = LoadLibraryW(L"shell32.dll");
HMODULE comdlg32, shell32
if (comdlg32 == NULL || shell32 == NULL)
comdlg32 = LoadLibraryW(L"comdlg32.dll");
if (comdlg32 == NULL)
{
return 0;
}
shell32 = LoadLibraryW(L"shell32.dll");
if (shell32 == NULL)
{
FreeLibrary(comdlg32);
return 0;
}
MyGetOpenFileName =
(void *) GetProcAddress(comdlg32, "GetOpenFileNameA");
MySHBrowseForFolder =