From e4c48945643460fca273217b75f3e7b72bb3ed7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 30 Jul 2023 14:56:10 +0200 Subject: [PATCH] [GDI32] CreateDIBSection: Remove erroneous assignation (#5502) bmBits is only used and assigned on output. It points (holds the address) to the array of DIB bit values. The "Bits" parameter is however a pointer to a variable that will receive the address of that array. So it makes no sense to initially assign bmBits to the value of the Bits parameter... --- win32ss/gdi/gdi32/objects/bitmap.c | 32 ++++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/win32ss/gdi/gdi32/objects/bitmap.c b/win32ss/gdi/gdi32/objects/bitmap.c index 5fbcf50568a..343b2b55bd0 100644 --- a/win32ss/gdi/gdi32/objects/bitmap.c +++ b/win32ss/gdi/gdi32/objects/bitmap.c @@ -255,34 +255,36 @@ CreateDIBSection( HBITMAP hBitmap = NULL; PVOID bmBits = NULL; - pConvertedInfo = ConvertBitmapInfo(BitmapInfo, Usage, &ConvertedInfoSize, - FALSE); - + pConvertedInfo = ConvertBitmapInfo(BitmapInfo, + Usage, + &ConvertedInfoSize, + FALSE); if (pConvertedInfo) { // Verify header due to converted may == info. if (pConvertedInfo->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) { - if (pConvertedInfo->bmiHeader.biCompression == BI_JPEG - || pConvertedInfo->bmiHeader.biCompression == BI_PNG) + if (pConvertedInfo->bmiHeader.biCompression == BI_JPEG || + pConvertedInfo->bmiHeader.biCompression == BI_PNG) { SetLastError(ERROR_INVALID_PARAMETER); return NULL; } } - bmBits = Bits; - hBitmap = NtGdiCreateDIBSection(hDC, hSection, dwOffset, pConvertedInfo, Usage, - ConvertedInfoSize, 0, // fl - 0, // dwColorSpace - &bmBits); + hBitmap = NtGdiCreateDIBSection(hDC, + hSection, + dwOffset, + pConvertedInfo, + Usage, + ConvertedInfoSize, + 0, // fl + 0, // dwColorSpace + &bmBits); + if (!hBitmap) + bmBits = NULL; if (BitmapInfo != pConvertedInfo) RtlFreeHeap(RtlGetProcessHeap(), 0, pConvertedInfo); - - if (!hBitmap) - { - bmBits = NULL; - } } if (Bits)