From ca403b662718bbbb684d81ab52b80e97a6a366dc Mon Sep 17 00:00:00 2001 From: xomx Date: Wed, 15 Nov 2023 16:49:37 +0100 Subject: [PATCH] Fix possible PluginsManager FindClose WINAPI errors Otherwise the ERROR_INVALID_HANDLE (0x6) can be triggered. Close #14356 --- PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 5c96dfa65..7991d4e0b 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -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; @@ -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) {