Author: tkreuzer Date: Wed Apr 25 19:25:48 2012 New Revision: 56425
URL: http://svn.reactos.org/svn/reactos?rev=56425&view=rev Log: [WIN32K] Make sure a bitmap is compatible with the dc before selecting it.
Modified: trunk/reactos/win32ss/gdi/ntgdi/dcobjs.c
Modified: trunk/reactos/win32ss/gdi/ntgdi/dcobjs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dcobjs.c?... ============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/dcobjs.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/dcobjs.c [iso-8859-1] Wed Apr 25 19:25:48 2012 @@ -265,6 +265,7 @@ PSURFACE psurfNew, psurfOld; HRGN hVisRgn; HDC hdcOld; + ULONG cBitsPixel; ASSERT_NOGDILOCKS();
/* Verify parameters */ @@ -329,24 +330,36 @@ return NULL; }
- /* Set the bitmap's hdc and check if it was set before */ - hdcOld = InterlockedCompareExchangePointer((PVOID*)&psurfNew->hdc, hdc, 0); - if (hdcOld != NULL) - { - /* The bitmap is already selected into a different DC */ - ASSERT(hdcOld != hdc); - + /* Check if the bitmap is compatile with the dc */ + cBitsPixel = gajBitsPerFormat[psurfNew->SurfObj.iBitmapFormat]; + if ((cBitsPixel != 1) && + (cBitsPixel != pdc->ppdev->gdiinfo.cBitsPixel) && + (psurfNew->hSecure == NULL)) + { /* Dereference the bitmap, unlock the DC and fail. */ SURFACE_ShareUnlockSurface(psurfNew); DC_UnlockDc(pdc); return NULL; }
+ /* Set the bitmap's hdc and check if it was set before */ + hdcOld = InterlockedCompareExchangePointer((PVOID*)&psurfNew->hdc, hdc, 0); + if (hdcOld != NULL) + { + /* The bitmap is already selected into a different DC */ + ASSERT(hdcOld != hdc); + + /* Dereference the bitmap, unlock the DC and fail. */ + SURFACE_ShareUnlockSurface(psurfNew); + DC_UnlockDc(pdc); + return NULL; + } + /* Copy the bitmap size */ pdc->dclevel.sizl = psurfNew->SurfObj.sizlBitmap;
/* Check if the bitmap is a dibsection */ - if(psurfNew->hSecure) + if (psurfNew->hSecure) { /* Set DIBSECTION attribute */ pdc->pdcattr->ulDirty_ |= DC_DIBSECTION;