Zhiyi Zhang : gdiplus: Report error for brush_fill_path().

Alexandre Julliard julliard at winehq.org
Wed Jun 20 17:13:13 CDT 2018


Module: wine
Branch: master
Commit: 07cf5ed18940a61d5477a611529cf17be18e5c5d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=07cf5ed18940a61d5477a611529cf17be18e5c5d

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Wed Jun 20 15:13:49 2018 +0800

gdiplus: Report error for brush_fill_path().

Operation should be skipped if SelectClipPath() returns any
error. And we should report unexpected error to the caller.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdiplus/graphics.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 894e879..a793665 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -1050,8 +1050,9 @@ static BOOL brush_can_fill_path(GpBrush *brush, BOOL is_fill)
     }
 }
 
-static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
+static GpStatus brush_fill_path(GpGraphics *graphics, GpBrush *brush)
 {
+    GpStatus status = Ok;
     switch (brush->bt)
     {
     case BrushTypeSolidColor:
@@ -1064,13 +1065,19 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
             RECT rc;
             /* partially transparent fill */
 
-            SelectClipPath(graphics->hdc, RGN_AND);
+            if (!SelectClipPath(graphics->hdc, RGN_AND))
+            {
+                status = GenericError;
+                DeleteObject(bmp);
+                break;
+            }
             if (GetClipBox(graphics->hdc, &rc) != NULLREGION)
             {
                 HDC hdc = CreateCompatibleDC(NULL);
 
                 if (!hdc)
                 {
+                    status = OutOfMemory;
                     DeleteObject(bmp);
                     break;
                 }
@@ -1091,7 +1098,11 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
         HBRUSH gdibrush, old_brush;
 
         gdibrush = create_gdi_brush(brush);
-        if (!gdibrush) return;
+        if (!gdibrush)
+        {
+            status = OutOfMemory;
+            break;
+        }
 
         old_brush = SelectObject(graphics->hdc, gdibrush);
         FillPath(graphics->hdc);
@@ -1100,6 +1111,8 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
         break;
     }
     }
+
+    return status;
 }
 
 static BOOL brush_can_fill_pixels(GpBrush *brush)
@@ -4205,7 +4218,7 @@ static GpStatus GDI32_GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath
     if(retval == Ok)
     {
         EndPath(graphics->hdc);
-        brush_fill_path(graphics, brush);
+        retval = brush_fill_path(graphics, brush);
     }
 
     gdi_transform_release(graphics);
@@ -4511,13 +4524,13 @@ static GpStatus GDI32_GdipFillRegion(GpGraphics* graphics, GpBrush* brush,
         Rectangle(graphics->hdc, rc.left, rc.top, rc.right, rc.bottom);
         EndPath(graphics->hdc);
 
-        brush_fill_path(graphics, brush);
+        status = brush_fill_path(graphics, brush);
     }
 
     RestoreDC(graphics->hdc, save_state);
 
 
-    return Ok;
+    return status;
 }
 
 static GpStatus SOFTWARE_GdipFillRegion(GpGraphics *graphics, GpBrush *brush,




More information about the wine-cvs mailing list