[PATCH] gdiplus: Silently ignore empty rectangles in GdipAddPathRectangles.

Vincent Povirk vincent at codeweavers.com
Wed Feb 28 09:49:29 CST 2018


Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
 dlls/gdiplus/graphicspath.c       |  3 +++
 dlls/gdiplus/tests/graphicspath.c | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index 8b13fc5b2a0..76ef1c248e2 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -2306,6 +2306,9 @@ GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y,
     if(!path)
         return InvalidParameter;
 
+    if (width <= 0.0 || height <= 0.0)
+        return Ok;
+
     /* make a backup copy of path data */
     if((retstat = GdipClonePath(path, &backup)) != Ok)
         return retstat;
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c
index 9a6dde3bd85..102c33c902a 100644
--- a/dlls/gdiplus/tests/graphicspath.c
+++ b/dlls/gdiplus/tests/graphicspath.c
@@ -1301,6 +1301,7 @@ static void test_empty_rect(void)
 {
     GpPath *path;
     GpStatus status;
+    INT count;
     BOOL result;
 
     status = GdipCreatePath(FillModeAlternate, &path);
@@ -1309,6 +1310,10 @@ static void test_empty_rect(void)
     status = GdipAddPathRectangle(path, 0.0, 0.0, -5.0, 5.0);
     expect(Ok, status);
 
+    status = GdipGetPointCount(path, &count);
+    expect(Ok, status);
+    expect(0, count);
+
     status = GdipIsVisiblePathPoint(path, -2.0, 2.0, NULL, &result);
     expect(Ok, status);
     expect(FALSE, status);
@@ -1316,12 +1321,31 @@ static void test_empty_rect(void)
     status = GdipAddPathRectangle(path, 0.0, 0.0, 5.0, -5.0);
     expect(Ok, status);
 
+    status = GdipGetPointCount(path, &count);
+    expect(Ok, status);
+    expect(0, count);
+
     status = GdipAddPathRectangle(path, 0.0, 0.0, 0.0, 5.0);
     expect(Ok, status);
 
+    status = GdipGetPointCount(path, &count);
+    expect(Ok, status);
+    expect(0, count);
+
     status = GdipAddPathRectangle(path, 0.0, 0.0, 5.0, 0.0);
     expect(Ok, status);
 
+    status = GdipGetPointCount(path, &count);
+    expect(Ok, status);
+    expect(0, count);
+
+    status = GdipAddPathRectangle(path, 0.0, 0.0, 5.0, 0.1);
+    expect(Ok, status);
+
+    status = GdipGetPointCount(path, &count);
+    expect(Ok, status);
+    expect(4, count);
+
     GdipDeletePath(path);
 }
 
-- 
2.14.1




More information about the wine-devel mailing list