Author: tkreuzer Date: Sat Jan 5 19:57:59 2013 New Revision: 58116
URL: http://svn.reactos.org/svn/reactos?rev=58116&view=rev Log: [WIN32K] In NtGdiStretchDIBitsInternal check early for info dc / mem dc without surface, only allocate memory and copy bits if the caller actually passed bits (they are optional), free the allocation, when an exception happens instead of leaking the memory.
Modified: trunk/reactos/win32ss/gdi/ntgdi/dibobj.c
Modified: trunk/reactos/win32ss/gdi/ntgdi/dibobj.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dibobj.c?... ============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/dibobj.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/dibobj.c [iso-8859-1] Sat Jan 5 19:57:59 2013 @@ -1071,6 +1071,14 @@ return 0; }
+ /* Check for info / mem DC without surface */ + if (!pdc->dclevel.pSurface) + { + DC_UnlockDc(pdc); + // CHECKME + return TRUE; + } + /* Transform dest size */ sizel.cx = cxDst; sizel.cy = cyDst; @@ -1099,22 +1107,30 @@ hcmXform); }
- pvBits = ExAllocatePoolWithTag(PagedPool, cjMaxBits, 'pmeT'); - if (!pvBits) - { - return 0; - } - - _SEH2_TRY - { - ProbeForRead(pjInit, cjMaxBits, 1); - RtlCopyMemory(pvBits, pjInit, cjMaxBits); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - _SEH2_YIELD(return 0); - } - _SEH2_END + if (pjInit && (cjMaxBits > 0)) + { + pvBits = ExAllocatePoolWithTag(PagedPool, cjMaxBits, 'pmeT'); + if (!pvBits) + { + return 0; + } + + _SEH2_TRY + { + ProbeForRead(pjInit, cjMaxBits, 1); + RtlCopyMemory(pvBits, pjInit, cjMaxBits); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + ExFreePoolWithTag(pvBits, 'pmeT'); + _SEH2_YIELD(return 0); + } + _SEH2_END + } + else + { + pvBits = NULL; + }
/* FIXME: Locking twice is cheesy, coord tranlation in UM will fix it */ if (!(pdc = DC_LockDc(hdc))) @@ -1171,13 +1187,6 @@ DC_vPrepareDCsForBlit(pdc, rcDst, NULL, rcSrc);
psurfDst = pdc->dclevel.pSurface; - if (!psurfDst) - { - DC_vFinishBlit(pdc, NULL); - // CHECKME - bResult = TRUE; - goto cleanup; - }
/* Initialize XLATEOBJ */ EXLATEOBJ_vInitialize(&exlo, @@ -1209,7 +1218,7 @@ if (psurfTmp) SURFACE_ShareUnlockSurface(psurfTmp); if (hbmTmp) GreDeleteObject(hbmTmp); if (pdc) DC_UnlockDc(pdc); - ExFreePoolWithTag(pvBits, 'pmeT'); + if (pvBits) ExFreePoolWithTag(pvBits, 'pmeT');
return bResult; }