From cdc2efb2415a804de63c2922df7f1ffebfa079ae Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 8 Mar 2015 22:44:36 +0000 Subject: [PATCH] [WIN32K] NtGdiSetDIBitsToDeviceInternal: Check for ScanLines == 0 and clean up exit pathes. Fixes assertion failure in gdi32_winetest:bitmap svn path=/trunk/; revision=66612 --- reactos/win32ss/gdi/ntgdi/dibobj.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/reactos/win32ss/gdi/ntgdi/dibobj.c b/reactos/win32ss/gdi/ntgdi/dibobj.c index 9bedfbfb8ff..72ad853f729 100644 --- a/reactos/win32ss/gdi/ntgdi/dibobj.c +++ b/reactos/win32ss/gdi/ntgdi/dibobj.c @@ -461,7 +461,7 @@ NtGdiSetDIBitsToDeviceInternal( { INT ret = 0; NTSTATUS Status = STATUS_SUCCESS; - PDC pDC; + PDC pDC = NULL; HBITMAP hSourceBitmap = NULL, hMaskBitmap = NULL; SURFOBJ *pDestSurf, *pSourceSurf = NULL, *pMaskSurf = NULL; SURFACE *pSurf; @@ -493,21 +493,25 @@ NtGdiSetDIBitsToDeviceInternal( if (!NT_SUCCESS(Status)) { - goto Exit2; + goto Exit; } ScanLines = min(ScanLines, abs(bmi->bmiHeader.biHeight) - StartScan); + if (ScanLines == 0) + { + DPRINT1("ScanLines == 0\n"); + goto Exit; + } pDC = DC_LockDc(hDC); if (!pDC) { EngSetLastError(ERROR_INVALID_HANDLE); - goto Exit2; + goto Exit; } if (pDC->dctype == DC_TYPE_INFO) { - DC_UnlockDc(pDC); goto Exit; } @@ -637,14 +641,13 @@ Exit: } if (ppalDIB) PALETTE_ShareUnlockPalette(ppalDIB); - if (pSourceSurf) EngUnlockSurface(pSourceSurf); if (hSourceBitmap) EngDeleteSurface((HSURF)hSourceBitmap); if (pMaskSurf) EngUnlockSurface(pMaskSurf); if (hMaskBitmap) EngDeleteSurface((HSURF)hMaskBitmap); - DC_UnlockDc(pDC); -Exit2: + if (pDC) DC_UnlockDc(pDC); ExFreePoolWithTag(pbmiSafe, 'pmTG'); + return ret; }