diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index eb097d97b..99c79cdbf 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -952,7 +952,6 @@ bool str2Clipboard(const generic_string &str2cpy, HWND hwnd) unsigned int clipBoardFormat = CF_UNICODETEXT; if (::SetClipboardData(clipBoardFormat, hglbCopy) == NULL) { - ::GlobalUnlock(hglbCopy); ::GlobalFree(hglbCopy); ::CloseClipboard(); return false; diff --git a/PowerEditor/src/MISC/Exception/MiniDumper.cpp b/PowerEditor/src/MISC/Exception/MiniDumper.cpp index 70ce5eb8b..7ef2cbe63 100644 --- a/PowerEditor/src/MISC/Exception/MiniDumper.cpp +++ b/PowerEditor/src/MISC/Exception/MiniDumper.cpp @@ -98,6 +98,7 @@ bool MiniDumper::writeDump(EXCEPTION_POINTERS * pExceptionInfo) { szResult = TEXT("The debugging DLL is outdated,\r\nfind a recent copy of dbghelp.dll and install it."); } + ::FreeLibrary(hDll); } else { diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 041503568..508821b33 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -345,7 +345,13 @@ bool PluginsManager::loadPluginsV2(const TCHAR* dir) generic_string dllName2 = foundData.cFileName; dllName2 += TEXT(".dll"); PathAppend(pluginsFullPathFilter2, dllName2); + // get plugin + if (hFindDll) + { + ::FindClose(hFindDll); + hFindDll = INVALID_HANDLE_VALUE; + } hFindDll = ::FindFirstFile(pluginsFullPathFilter2.c_str(), &foundData); if (hFindDll != INVALID_HANDLE_VALUE && !(foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp index 3a1cf51b2..fb203eeb7 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp @@ -79,7 +79,7 @@ void Version::setVersionFrom(generic_string filePath) { if (not filePath.empty() && ::PathFileExists(filePath.c_str())) { - DWORD handle; + DWORD handle = 0; DWORD bufferSize = ::GetFileVersionInfoSize(filePath.c_str(), &handle); if (bufferSize <= 0) @@ -88,9 +88,9 @@ void Version::setVersionFrom(generic_string filePath) unsigned char* buffer = new unsigned char[bufferSize]; ::GetFileVersionInfo(filePath.c_str(), handle, bufferSize, buffer); - VS_FIXEDFILEINFO* lpFileInfo; + VS_FIXEDFILEINFO* lpFileInfo = nullptr; UINT cbFileInfo = 0; - VerQueryValue(buffer, TEXT("\\"), (LPVOID*)&lpFileInfo, &cbFileInfo); + VerQueryValue(buffer, TEXT("\\"), reinterpret_cast(&lpFileInfo), &cbFileInfo); if (cbFileInfo) { _major = (lpFileInfo->dwFileVersionMS & 0xFFFF0000) >> 16; @@ -98,6 +98,7 @@ void Version::setVersionFrom(generic_string filePath) _patch = (lpFileInfo->dwFileVersionLS & 0xFFFF0000) >> 16; _build = lpFileInfo->dwFileVersionLS & 0x0000FFFF; } + delete[] buffer; } } @@ -714,7 +715,10 @@ bool PluginsAdminDlg::isValide() bool PluginsAdminDlg::updateListAndLoadFromJson() { - try { + HMODULE hLib = NULL; + + try + { if (!isValide()) return false; @@ -728,7 +732,7 @@ bool PluginsAdminDlg::updateListAndLoadFromJson() #else //RELEASE - HINSTANCE hLib = ::LoadLibrary(_pluginListFullPath.c_str()); + hLib = ::LoadLibrary(_pluginListFullPath.c_str()); if (!hLib) { // Error treatment @@ -741,6 +745,7 @@ bool PluginsAdminDlg::updateListAndLoadFromJson() { // Error treatment //printStr(TEXT("getList PB!!!")); + ::FreeLibrary(hLib); return false; } @@ -770,11 +775,14 @@ bool PluginsAdminDlg::updateListAndLoadFromJson() // initialize installed list view loadFromPluginInfos(); + ::FreeLibrary(hLib); return true; } catch (...) { // whichever exception + if (hLib) + ::FreeLibrary(hLib); return false; } }