https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8b19b6ec5abcaf3603e14…
commit 8b19b6ec5abcaf3603e147252fa87fce998ec79e
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Mon Jan 16 14:24:07 2023 -0500
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Fri Jan 27 22:30:35 2023 -0500
[GDI32] Fix memory leak in case of public DC. CORE-18498
---
win32ss/gdi/gdi32/objects/bitmap.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/win32ss/gdi/gdi32/objects/bitmap.c b/win32ss/gdi/gdi32/objects/bitmap.c
index 438521f69e9..b029d4ad2df 100644
--- a/win32ss/gdi/gdi32/objects/bitmap.c
+++ b/win32ss/gdi/gdi32/objects/bitmap.c
@@ -756,8 +756,10 @@ SetDIBitsToDevice(
if (!GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID) & pDc_Attr))
{
+ DPRINT1("SetDIBitsToDevice called on invalid DC %p (not owned?)\n",
hdc);
SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
+ LinesCopied = 0;
+ goto Exit;
}
/*
if ( !pDc_Attr || // DC is Public
@@ -867,8 +869,10 @@ StretchDIBits(
if (!GdiGetHandleUserData(hdc, GDI_OBJECT_TYPE_DC, (PVOID) & pDc_Attr))
{
+ DPRINT1("StretchDIBits called on invalid DC %p (not owned?)\n", hdc);
SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
+ LinesCopied = 0;
+ goto Exit;
}
/*
if ( !pDc_Attr ||
@@ -894,6 +898,7 @@ StretchDIBits(
cjBmpScanSize,
NULL );
}
+Exit:
if (pvSafeBits)
RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits);
if (lpBitsInfo != pConvertedInfo)