Handle NULL values in IntRoundRect and NtGdiEllipse
Modified: trunk/reactos/subsys/win32k/objects/fillshap.c

Modified: trunk/reactos/subsys/win32k/objects/fillshap.c
--- trunk/reactos/subsys/win32k/objects/fillshap.c	2005-02-20 16:46:10 UTC (rev 13689)
+++ trunk/reactos/subsys/win32k/objects/fillshap.c	2005-02-20 17:35:50 UTC (rev 13690)
@@ -260,8 +260,14 @@
    }
 
    BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
-   /* FIXME - BitmapObj can be NULL!!!! Don't assert but handle this case gracefully! */
-   ASSERT(BitmapObj);
+   if (NULL = BitmapObj)
+   {
+      BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+      BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
+      DC_UnlockDc(hDC);
+      SetLastWin32Error(ERROR_INTERNAL_ERROR);
+      return FALSE;
+   }
 
    IntGdiInitBrushInstance(&FillBrushInst, FillBrush, dc->XlateBrush);
    IntGdiInitBrushInstance(&PenBrushInst, PenBrush, dc->XlatePen);
@@ -1113,30 +1119,44 @@
   RectBounds.bottom = bottom;
 
   BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
-  /* FIXME - BitmapObj can be NULL!!!! Handle this case gracefully instead of ASSERT! */
-  ASSERT(BitmapObj);
+  if (!BitmapObj)
+  {
+    /* Nothing to do, as we don't have a bitmap */
+    BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
+    SetLastWin32Error(ERROR_INTERNAL_ERROR);
+    return FALSE;
+  }
 
   FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
-  /* FIXME - Don't assert if FillBrushObj == NULL, handle this case !!!! */
-  ASSERT(FillBrushObj);
-  if (FillBrushObj->flAttrs & GDIBRUSH_IS_NULL)
+  if (FillBrushObj)
   {
-    BRUSHOBJ_UnlockBrush(dc->w.hBrush);
-    FillBrushObj = NULL; // make null brush check simpler...
+    if (FillBrushObj->flAttrs & GDIBRUSH_IS_NULL)
+    {
+      /* make null brush check simpler... */
+      BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+      FillBrushObj = NULL;
+    }
+    else
+    {
+      IntGdiInitBrushInstance(&FillBrushInst, FillBrushObj, dc->XlateBrush);
+    }
   }
 
   PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
-  /* FIXME - PenBrushObject can be NULL!!! Don't assert!!!! */
-  ASSERT(PenBrushObj);
-  if (PenBrushObj->flAttrs & GDIBRUSH_IS_NULL)
+  if (PenBrushObj)
   {
-    PENOBJ_UnlockPen(dc->w.hPen);
-    PenBrushObj = NULL;
+    if (PenBrushObj->flAttrs & GDIBRUSH_IS_NULL)
+    {
+      /* make null pen check simpler... */
+      PENOBJ_UnlockPen(dc->w.hPen);
+      PenBrushObj = NULL;
+    }
+    else
+    {
+      IntGdiInitBrushInstance(&PenBrushInst, PenBrushObj, dc->XlatePen);
+    }
   }
 
-  IntGdiInitBrushInstance(&FillBrushInst, FillBrushObj, dc->XlateBrush);
-  IntGdiInitBrushInstance(&PenBrushInst, PenBrushObj, dc->XlatePen);
-
   right--;
   bottom--;
 
@@ -1317,7 +1337,8 @@
   BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
   if(PenBrushObj != NULL)
     PENOBJ_UnlockPen(dc->w.hPen);
-  BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+  if(FillBrushObj != NULL)
+    BRUSHOBJ_UnlockBrush(dc->w.hBrush);
 
   return ret;
 }