Signed-off-by: Jeff Smith whydoubt@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);
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/gdiplus/graphicspath.c | 2 +- dlls/gdiplus/tests/graphicspath.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index 2b191dd30d..4d5a73588f 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -627,7 +627,7 @@ GpStatus WINGDIPAPI GdipAddPathLine2(GpPath *path, GDIPCONST GpPointF *points,
TRACE("(%p, %p, %d)\n", path, points, count);
- if(!path || !points) + if(!path || !points || count < 1) return InvalidParameter;
if(!lengthen_path(path, count)) diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 0c5297249a..7670a6c41f 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -308,6 +308,16 @@ static void test_line2(void) }
GdipCreatePath(FillModeAlternate, &path); + + status = GdipAddPathLine2(NULL, line2_points, 2); + expect(InvalidParameter, status); + status = GdipAddPathLine2(path, NULL, 2); + expect(InvalidParameter, status); + status = GdipAddPathLine2(path, line2_points, 0); + expect(InvalidParameter, status); + status = GdipAddPathLine2(path, line2_points, -1); + expect(InvalidParameter, status); + status = GdipAddPathLine2(path, line2_points, 3); expect(Ok, status); status = GdipAddPathLine2(path, &(line2_points[3]), 3);
Signed-off-by: Vincent Povirk vincent@codeweavers.com