[EXPLORER] Fix handle leaks (#8516)

JIRA issue: CORE-15616
JIRA issue: CORE-14382

The Explorer shell has multiple resource leaks causing handle exhaustion over extended use.
This commit is contained in:
Copilot
2026-01-01 22:13:00 +09:00
committed by GitHub
parent d2ae286c6b
commit 1d409e322b
3 changed files with 26 additions and 3 deletions

View File

@@ -168,6 +168,7 @@ public:
void RefreshToolbarMetrics(BOOL bForceRefresh);
private:
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnCtxMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
VOID SendMouseEvent(IN WORD wIndex, IN UINT uMsg, IN WPARAM wParam);
LRESULT OnMouseEvent(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
@@ -175,6 +176,7 @@ private:
public:
BEGIN_MSG_MAP(CNotifyToolbar)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
MESSAGE_HANDLER(WM_CONTEXTMENU, OnCtxMenu)
MESSAGE_RANGE_HANDLER(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseEvent)
NOTIFY_CODE_HANDLER(TTN_SHOW, OnTooltipShow)
@@ -1031,6 +1033,17 @@ VOID CNotifyToolbar::ResizeImagelist()
SetButtonSize(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
}
LRESULT CNotifyToolbar::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if (m_ImageList)
{
ImageList_Destroy(m_ImageList);
m_ImageList = NULL;
}
return 0;
}
LRESULT CNotifyToolbar::OnCtxMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
bHandled = FALSE;

View File

@@ -276,7 +276,6 @@ public:
if (!m_hThread)
{
m_bThreadRunning = FALSE;
CloseHandle(m_hThread);
}
}
};
@@ -1557,6 +1556,13 @@ public:
CloseThemeData(m_Theme);
DeleteAllTasks();
if (m_ImageList)
{
ImageList_Destroy(m_ImageList);
m_ImageList = NULL;
}
return TRUE;
}

View File

@@ -533,7 +533,9 @@ public:
}
}
CloseHandle(CreateThread(NULL, 0, s_RunFileDlgThread, this, 0, NULL));
HANDLE hThread = CreateThread(NULL, 0, s_RunFileDlgThread, this, 0, NULL);
if (hThread)
CloseHandle(hThread);
}
DWORD WINAPI TrayPropertiesThread()
@@ -587,7 +589,9 @@ public:
}
}
CloseHandle(CreateThread(NULL, 0, s_TrayPropertiesThread, this, 0, NULL));
HANDLE hThread = CreateThread(NULL, 0, s_TrayPropertiesThread, this, 0, NULL);
if (hThread)
CloseHandle(hThread);
return NULL;
}