[ros-diffs] [greatlrd] 33885: BugFix : NtGdiStretchDIBitsInternal it did not check after some NULL pointer and did crash in firefox. and some reason NtGdiCreateCompatibleBitmap fail in some case, that what happen in firefox 1.5.

greatlrd at svn.reactos.org greatlrd at svn.reactos.org
Sat Jun 7 13:35:54 CEST 2008


Author: greatlrd
Date: Sat Jun  7 06:35:53 2008
New Revision: 33885

URL: http://svn.reactos.org/svn/reactos?rev=33885&view=rev
Log:
BugFix : NtGdiStretchDIBitsInternal 
it did not check after some NULL pointer and did crash in firefox. 
and some reason  NtGdiCreateCompatibleBitmap fail in some case, that what happen in firefox 1.5.

Modified:
    trunk/reactos/subsystems/win32/win32k/objects/dibobj.c

Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/dibobj.c?rev=33885&r1=33884&r2=33885&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Sat Jun  7 06:35:53 2008
@@ -781,7 +781,7 @@
     UINT cjMaxBits,
     HANDLE hcmXform)
 {
-   HBITMAP hBitmap, hOldBitmap;
+   HBITMAP hBitmap, hOldBitmap = NULL;
    HDC hdcMem;
    HPALETTE hPal = NULL;
    PDC pDC;
@@ -793,9 +793,22 @@
    }
 
    hdcMem = NtGdiCreateCompatibleDC(hDC);
+   if (hdcMem == NULL)
+   {
+       DPRINT1("NtGdiCreateCompatibleDC fail create hdc\n");
+       return 0;
+   }
+
    hBitmap = NtGdiCreateCompatibleBitmap(hDC, BitsInfo->bmiHeader.biWidth,
                                          BitsInfo->bmiHeader.biHeight);
-   hOldBitmap = NtGdiSelectBitmap(hdcMem, hBitmap);
+   if (hBitmap == NULL)
+   {
+       DPRINT1("NtGdiCreateCompatibleBitmap fail create bitmap\n");
+       DPRINT1("hDC : 0x%08x \n", hDC);
+       DPRINT1("BitsInfo->bmiHeader.biWidth : 0x%08x \n", BitsInfo->bmiHeader.biWidth);
+       DPRINT1("BitsInfo->bmiHeader.biWidth : 0x%08x \n", BitsInfo->bmiHeader.biHeight);
+       return 0;
+   }
 
    if(Usage == DIB_PAL_COLORS)
    {
@@ -817,16 +830,18 @@
    }
 
    pDC = DC_LockDc(hdcMem);
-
-   /* Note BitsInfo->bmiHeader.biHeight is the number of scanline, 
-    * if it negitve we getting to many scanline for scanline is UINT not
-    * a INT, so we need make the negtive value to positve and that make the
-    * count correct for negtive bitmap, TODO : we need testcase for this api */
-
-   IntSetDIBits(pDC, hBitmap, 0, abs(BitsInfo->bmiHeader.biHeight), Bits,
+   if (pDC != NULL) 
+   {
+        /* Note BitsInfo->bmiHeader.biHeight is the number of scanline, 
+         * if it negitve we getting to many scanline for scanline is UINT not
+         * a INT, so we need make the negtive value to positve and that make the
+         * count correct for negtive bitmap, TODO : we need testcase for this api */
+
+         IntSetDIBits(pDC, hBitmap, 0, abs(BitsInfo->bmiHeader.biHeight), Bits,
                   BitsInfo, Usage);
 
-   DC_UnlockDc(pDC);
+        DC_UnlockDc(pDC);
+   }
 
 
    /* Origin for DIBitmap may be bottom left (positive biHeight) or top
@@ -840,11 +855,17 @@
                       hdcMem, XSrc, abs(BitsInfo->bmiHeader.biHeight) - SrcHeight - YSrc,
                       SrcWidth, SrcHeight, ROP, 0);
 
+    /* cleanup */
    if(hPal)
       GdiSelectPalette(hdcMem, hPal, FALSE);
 
-   NtGdiSelectBitmap(hdcMem, hOldBitmap);
+   if (hOldBitmap != NULL)
+   {
+        NtGdiSelectBitmap(hdcMem, hOldBitmap);
+   }
+
    NtGdiDeleteObjectApp(hdcMem);
+
    NtGdiDeleteObject(hBitmap);
 
    return SrcHeight;



More information about the Ros-diffs mailing list