don't pass NULL handles to NtGdiCombineRgn
Modified: trunk/reactos/subsys/win32k/ntuser/painting.c
Modified: trunk/reactos/subsys/win32k/ntuser/windc.c

Modified: trunk/reactos/subsys/win32k/ntuser/painting.c
--- trunk/reactos/subsys/win32k/ntuser/painting.c	2005-02-19 03:38:43 UTC (rev 13639)
+++ trunk/reactos/subsys/win32k/ntuser/painting.c	2005-02-19 11:13:41 UTC (rev 13640)
@@ -309,19 +309,20 @@
          -Window->WindowRect.top);
 
       hRgnNonClient = NtGdiCreateRectRgn(0, 0, 0, 0);
-      GDIOBJ_SetOwnership(hRgnNonClient, NULL);
       if (NtGdiCombineRgn(hRgnNonClient, Window->UpdateRegion,
           hRgnWindow, RGN_DIFF) == NULLREGION)
       {
-         GDIOBJ_SetOwnership(hRgnNonClient, PsGetCurrentProcess());
          NtGdiDeleteObject(hRgnNonClient);
          hRgnNonClient = NULL;
       }
+      else
+      {
+         GDIOBJ_SetOwnership(hRgnNonClient, NULL);
+      }
 
       /*
        * Remove the nonclient region from the standard update region.
        */
-
       if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
           hRgnWindow, RGN_AND) == NULLREGION)
       {
@@ -336,12 +337,12 @@
       }
       else
       {
-         NtGdiCombineRgn(Window->NCUpdateRegion, Window->NCUpdateRegion,
-            hRgnNonClient, RGN_OR);
-         if (NULL != hRgnNonClient)
+         if(NULL != hRgnNonClient)
          {
-            GDIOBJ_SetOwnership(hRgnNonClient, PsGetCurrentProcess());
-            NtGdiDeleteObject(hRgnNonClient);
+           NtGdiCombineRgn(Window->NCUpdateRegion, Window->NCUpdateRegion,
+               hRgnNonClient, RGN_OR);
+           GDIOBJ_SetOwnership(hRgnNonClient, PsGetCurrentProcess());
+           NtGdiDeleteObject(hRgnNonClient);
          }
       }
 

Modified: trunk/reactos/subsys/win32k/ntuser/windc.c
--- trunk/reactos/subsys/win32k/ntuser/windc.c	2005-02-19 03:38:43 UTC (rev 13639)
+++ trunk/reactos/subsys/win32k/ntuser/windc.c	2005-02-19 11:13:41 UTC (rev 13640)
@@ -213,7 +213,7 @@
     {
       Dce->DCXFlags &= ~DCX_KEEPCLIPRGN;
     }
-  else if (Dce->hClipRgn > (HRGN) 1)
+  else if (Dce->hClipRgn != NULL)
     {
       GDIOBJ_SetOwnership(Dce->hClipRgn, PsGetCurrentProcess());
       NtGdiDeleteObject(Dce->hClipRgn);
@@ -332,10 +332,21 @@
 noparent:
    if (Flags & DCX_INTERSECTRGN)
    {
-      NtGdiCombineRgn(hRgnVisible, hRgnVisible, Dce->hClipRgn, RGN_AND);
+      if(Dce->hClipRgn != NULL)
+      {
+         NtGdiCombineRgn(hRgnVisible, hRgnVisible, Dce->hClipRgn, RGN_AND);
+      }
+      else
+      {
+         if(hRgnVisible != NULL)
+         {
+            NtGdiDeleteObject(hRgnVisible);
+         }
+         hRgnVisible = NtGdiCreateRectRgn(0, 0, 0, 0);
+      }
    }
 
-   if (Flags & DCX_EXCLUDERGN)
+   if (Flags & DCX_EXCLUDERGN && Dce->hClipRgn != NULL)
    {
       NtGdiCombineRgn(hRgnVisible, hRgnVisible, Dce->hClipRgn, RGN_DIFF);
    }