Skip to content

Commit

Permalink
Fix possible PluginsManager FindClose WINAPI errors
Browse files Browse the repository at this point in the history
Otherwise the ERROR_INVALID_HANDLE (0x6) can be triggered.

Close notepad-plus-plus#14356
  • Loading branch information
xomx authored and donho committed Nov 15, 2023
1 parent 1764758 commit ca403b6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ bool PluginsManager::loadPlugins(const TCHAR* dir, const PluginViewList* pluginU
pathAppend(pluginsFullPathFilter2, dllName2);

// get plugin
if (hFindDll)
if (hFindDll && (hFindDll != INVALID_HANDLE_VALUE))
{
::FindClose(hFindDll);
hFindDll = INVALID_HANDLE_VALUE;
Expand Down Expand Up @@ -514,8 +514,10 @@ bool PluginsManager::loadPlugins(const TCHAR* dir, const PluginViewList* pluginU
}

}
::FindClose(hFindFolder);
::FindClose(hFindDll);
if (hFindFolder && (hFindFolder != INVALID_HANDLE_VALUE))
::FindClose(hFindFolder);
if (hFindDll && (hFindDll != INVALID_HANDLE_VALUE))
::FindClose(hFindDll);

for (size_t i = 0, len = dllNames.size(); i < len; ++i)
{
Expand Down

0 comments on commit ca403b6

Please sign in to comment.