gdiplus: Handle zero width/height in GdipAddPathPie.

Nikolay Sivov bunglehead at gmail.com
Mon Feb 9 14:38:30 CST 2009


http://bugs.winehq.org/show_bug.cgi?id=17291

On zero height/width a broken path returned with only one point in it.

Changelog:
    Handle zero width/height in GdipAddPathPie

>From 3465ad9ed6a24b3c3231921703561638db132e27 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Mon, 9 Feb 2009 23:25:06 +0300
Subject: Handle zero width/height in GdipAddPathPie

---
 dlls/gdiplus/graphicspath.c       |   11 +++++++++++
 dlls/gdiplus/tests/graphicspath.c |   21 ++++++++++++++++++++-
 2 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index 042d4a2..4703ace 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -723,6 +723,17 @@ GpStatus WINGDIPAPI GdipAddPathPie(GpPath *path, REAL x, REAL y, REAL width, REA
     if(!path)
         return InvalidParameter;
 
+    /* on zero width/height only start point added */
+    if(width <= 1e-7 || height <= 1e-7){
+        if(!lengthen_path(path, 1))
+            return OutOfMemory;
+        path->pathdata.Points[0].X = x + width  / 2.0;
+        path->pathdata.Points[0].Y = y + height / 2.0;
+        path->pathdata.Types[0] = PathPointTypeStart | PathPointTypeCloseSubpath;
+        path->pathdata.Count = 1;
+        return InvalidParameter;
+    }
+
     count = arc2polybezier(NULL, x, y, width, height, startAngle, sweepAngle);
 
     if(count == 0)
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c
index 416d80c..d256cac 100644
--- a/dlls/gdiplus/tests/graphicspath.c
+++ b/dlls/gdiplus/tests/graphicspath.c
@@ -907,7 +907,12 @@ static path_test_t addpie_path[] = {
     {79.4, 46.8, PathPointTypeBezier,0, 0}, /*3*/
     {63.9, 49.0, PathPointTypeBezier | PathPointTypeCloseSubpath,  0, 0} /*4*/
     };
-
+static path_test_t addpie_path2[] = {
+    {0.0, 30.0, PathPointTypeStart | PathPointTypeCloseSubpath, 0, 0} /*0*/
+    };
+static path_test_t addpie_path3[] = {
+    {30.0, 0.0, PathPointTypeStart | PathPointTypeCloseSubpath, 0, 0} /*0*/
+    };
 static void test_addpie(void)
 {
     GpStatus status;
@@ -922,6 +927,20 @@ static void test_addpie(void)
     status = GdipAddPathPie(path, 0.0, 0.0, 100.0, 50.0, 10.0, 50.0);
     expect(Ok, status);
     ok_path(path, addpie_path, sizeof(addpie_path)/sizeof(path_test_t), FALSE);
+    status = GdipResetPath(path);
+    expect(Ok, status);
+
+    /* zero width base ellipse */
+    status = GdipAddPathPie(path, 0.0, 0.0, 0.0, 60.0, -90.0, 24.0);
+    expect(InvalidParameter, status);
+    ok_path(path, addpie_path2, sizeof(addpie_path2)/sizeof(path_test_t), FALSE);
+    status = GdipResetPath(path);
+    expect(Ok, status);
+
+    /* zero height base ellipse */
+    status = GdipAddPathPie(path, 0.0, 0.0, 60.0, 0.0 , -90.0, 24.0);
+    expect(InvalidParameter, status);
+    ok_path(path, addpie_path3, sizeof(addpie_path3)/sizeof(path_test_t), FALSE);
 
     GdipDeletePath(path);
 }
-- 
1.5.6.5






More information about the wine-patches mailing list