From 818c6c4afcf4384c8856fd8144b05c8f991dae6b Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Thu, 3 Sep 2015 07:01:29 +0000 Subject: [PATCH] [EXPLORER] proper fix for CID 1321923, 1321924 svn path=/trunk/; revision=68924 --- reactos/base/shell/explorer/traywnd.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/reactos/base/shell/explorer/traywnd.cpp b/reactos/base/shell/explorer/traywnd.cpp index f4cca036335..5b3bb40ba27 100644 --- a/reactos/base/shell/explorer/traywnd.cpp +++ b/reactos/base/shell/explorer/traywnd.cpp @@ -190,7 +190,7 @@ DefSize: HDC hDC = NULL; HDC hDCScreen = NULL; SIZE Size, SmallIcon; - HBITMAP hbmpOld; + HBITMAP hbmpOld, hbmp = NULL; HBITMAP hBitmap = NULL; HICON hIconStart; BOOL Ret; @@ -243,10 +243,10 @@ DefSize: Size.cy = max(Size.cy, SmallIcon.cy); /* Create the bitmap */ - hBitmap = CreateCompatibleBitmap(hDCScreen, + hbmp = CreateCompatibleBitmap(hDCScreen, Size.cx, Size.cy); - if (hBitmap == NULL) + if (hbmp == NULL) goto Cleanup; /* Caluclate the button rect */ @@ -256,13 +256,13 @@ DefSize: rcButton.bottom = Size.cy; /* Draw the button */ - hbmpOld = (HBITMAP) SelectObject(hDC, hBitmap); + hbmpOld = (HBITMAP) SelectObject(hDC, hbmp); Flags = DC_TEXT | DC_INBUTTON; if (hIconStart != NULL) Flags |= DC_ICON; - DrawCaptionTemp(NULL, + Ret = DrawCaptionTemp(NULL, hDC, &rcButton, m_Font, @@ -275,12 +275,19 @@ DefSize: if (!Ret) goto Cleanup; + /* We successfully created the bitmap! */ + hBitmap = hbmp; + hbmp = NULL; + Cleanup: if (hDCScreen != NULL) { ::ReleaseDC(NULL, hDCScreen); } + if (hbmp != NULL) + DeleteObject(hbmp); + if (hDC != NULL) DeleteDC(hDC);