From ce44d63bc3de7e6f95726f943e095c9f34f94365 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 11 Dec 2023 19:32:09 +0100 Subject: [PATCH] qt_imageToWinHBITMAP(): properly delete object on error Properly delete the handle created by CreateDIBSection() with DeleteObject() in case of error. Pick-to: 6.6 6.5 Fixes: QTBUG-18057 Change-Id: Ibf40f6afb255bc5a7d7bf39939f5eb3dfcd19f84 Reviewed-by: Axel Spoerl (cherry picked from commit b37b8eb7ea0a809c6e96189e8f9e834d6763e170) Reviewed-by: Qt Cherry-pick Bot --- src/gui/image/qpixmap_win.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp index d52e624752a..fc601bccfc1 100644 --- a/src/gui/image/qpixmap_win.cpp +++ b/src/gui/image/qpixmap_win.cpp @@ -305,6 +305,7 @@ HBITMAP qt_imageToWinHBITMAP(const QImage &imageIn, int hbitmapFormat) return nullptr; } if (!pixels) { + DeleteObject(bitmap); qErrnoWarning("%s, did not allocate pixel data", __FUNCTION__); return nullptr; }