Signed-off-by: Jeff Smith <whydoubt(a)gmail.com>
---
dlls/gdiplus/graphicspath.c | 3 +++
dlls/gdiplus/tests/graphicspath.c | 13 ++++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index df6a32d22d..2b191dd30d 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -1228,6 +1228,9 @@ GpStatus WINGDIPAPI GdipCreatePath2(GDIPCONST GpPointF* points,
*path = heap_alloc_zero(sizeof(GpPath));
if(!*path) return OutOfMemory;
+ if(count > 1 && (types[count-1] & PathPointTypePathTypeMask) == PathPointTypeStart)
+ count = 0;
+
for(i = 1; i < count; i++) {
if((types[i] & PathPointTypePathTypeMask) == PathPointTypeBezier) {
if(i+2 < count &&
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c
index 1b3a9a161f..0c5297249a 100644
--- a/dlls/gdiplus/tests/graphicspath.c
+++ b/dlls/gdiplus/tests/graphicspath.c
@@ -181,8 +181,8 @@ static void test_createpath2(void)
GpPathData data;
INT i, count, expect_count;
- PointF test_line_points[] = {{1.0,1.0}, {2.0,1.0}};
- BYTE test_line_types[] = {PathPointTypeStart, PathPointTypeLine};
+ PointF test_line_points[] = {{1.0,1.0}, {2.0,1.0}, {2.0,2.0}};
+ BYTE test_line_types[] = {PathPointTypeStart, PathPointTypeLine, PathPointTypeStart};
PointF test_bez_points[] = {{1.0,1.0}, {2.0,1.0}, {3.0,1.0}, {4.0,1.0},
{5.0,1.0}, {6.0,1.0}, {7.0,1.0}};
@@ -235,8 +235,15 @@ static void test_createpath2(void)
status = GdipCreatePath2(test_line_points, test_line_types, 2, FillModeAlternate, NULL);
expect(InvalidParameter, status);
+ /* Multi-point paths should not end with Start */
+ status = GdipCreatePath2(test_line_points, test_line_types, 3, FillModeAlternate, &path);
+ expect(Ok, status);
+ status = GdipGetPointCount(path, &count);
+ expect(Ok, status);
+ expect(0, count);
+ GdipDeletePath(path);
+
/* Zero-length line points do not get altered */
- path = NULL;
test_line_points[1].X = test_line_points[0].X;
test_line_points[1].Y = test_line_points[0].Y;
status = GdipCreatePath2(test_line_points, test_line_types, 2, FillModeAlternate, &path);
--
2.23.0