From 9d95787d3cf25b3f9ae3c343055d0255df328338 Mon Sep 17 00:00:00 2001 From: hdlx Date: Fri, 30 Aug 2024 15:49:53 +0200 Subject: [PATCH] Fix potential leak and crash --- Sources/App.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sources/App.c b/Sources/App.c index 4053723..3a5b076 100644 --- a/Sources/App.c +++ b/Sources/App.c @@ -1366,8 +1366,13 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) x += iconContainerSize; } BitBlt(ps.hdc, clientRect.left, clientRect.top, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top, pGraphRes->_DC, 0, 0, SRCCOPY); + + // Always restore old bitmap (see fn doc) + SelectObject(pGraphRes->_DC, oldBitmap); + GdipDeleteGraphics(pGraphics); EndPaint(hwnd, &ps); + return 0; } case WM_ERASEBKGND: