From be396627674fd2d7bc0bfd734137d328ffa819d8 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Dec 2025 08:12:57 +0900 Subject: [PATCH] [TASKMGR] Fix a handle leak of ReleaseDC (#8513) JIRA issue: CORE-20230 Fix a handle leak that forgot ReleaseDC(hParentWnd, hdc); on failure. --- base/applications/taskmgr/graphctl.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/base/applications/taskmgr/graphctl.c b/base/applications/taskmgr/graphctl.c index 3f34ddf016e..1784fc8aa20 100644 --- a/base/applications/taskmgr/graphctl.c +++ b/base/applications/taskmgr/graphctl.c @@ -67,18 +67,15 @@ GraphCtrl_Create(PTM_GRAPH_CONTROL inst, HWND hWnd, HWND hParentWnd, PTM_FORMAT inst->ftPixelsPerPercent = (FLOAT)(inst->BitmapHeight) / 100.00f; hdc = GetDC(hParentWnd); - hdcg = CreateCompatibleDC(hdc); - inst->hdcGraph = hdcg; - inst->hbmGraph = CreateCompatibleBitmap(hdc, inst->BitmapWidth, inst->BitmapHeight); - - if (!hdc || - !hdcg || - !inst->hbmGraph) - { + if (!hdc) goto fail; - } + inst->hdcGraph = hdcg = CreateCompatibleDC(hdc); + inst->hbmGraph = CreateCompatibleBitmap(hdc, inst->BitmapWidth, inst->BitmapHeight); ReleaseDC(hParentWnd, hdc); + if (!hdcg || !inst->hbmGraph) + goto fail; + hbmOld = (HBITMAP)SelectObject(hdcg, inst->hbmGraph); DeleteObject(hbmOld);