[PATCH v4 0/2] MR3461: gdiplus: Reject zero-width/zero-height rectangles
Works around the issue manifesting here : https://bugs.winehq.org/show_bug.cgi?id=55351 The MR also contains a patch that refactors the related tests a bit. Signed-off-by: David Kahurani k.kahurani(a)gmail.com -- v4: gdiplus: Move Flatten() tests into the same function gdiplus: Reject zero-width/zero-height rectangles https://gitlab.winehq.org/wine/wine/-/merge_requests/3461
From: David Kahurani <k.kahurani(a)gmail.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55351 Signed-off-by: David Kahurani <k.kahurani(a)gmail.com> --- dlls/gdiplus/graphicspath.c | 20 ++++++++++---------- dlls/gdiplus/tests/graphicspath.c | 27 ++++++++++++++------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index 545aaa8441e..fd2622daf0e 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -283,10 +283,10 @@ static GpStatus extend_current_figure(GpPath *path, GDIPCONST PointF *points, IN * * PARAMS * path [I/O] Path that the arc is appended to - * x1 [I] X coordinate of the boundary box - * y1 [I] Y coordinate of the boundary box - * x2 [I] Width of the boundary box - * y2 [I] Height of the boundary box + * x [I] X coordinate of the boundary rectangle + * y [I] Y coordinate of the boundary rectangle + * width [I] Width of the boundary rectangle + * height [I] Height of the boundary rectangle * startAngle [I] Starting angle of the arc, clockwise * sweepAngle [I] Angle of the arc, clockwise * @@ -302,20 +302,20 @@ static GpStatus extend_current_figure(GpPath *path, GDIPCONST PointF *points, IN * In both cases, the value of newfigure of the given path is FALSE * afterwards. */ -GpStatus WINGDIPAPI GdipAddPathArc(GpPath *path, REAL x1, REAL y1, REAL x2, - REAL y2, REAL startAngle, REAL sweepAngle) +GpStatus WINGDIPAPI GdipAddPathArc(GpPath *path, REAL x, REAL y, REAL width, + REAL height, REAL startAngle, REAL sweepAngle) { GpPointF *points; GpStatus status; INT count; TRACE("(%p, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f)\n", - path, x1, y1, x2, y2, startAngle, sweepAngle); + path, x, y, width, height, startAngle, sweepAngle); - if(!path) + if(!path || width <= 0.0f || height <= 0.0f) return InvalidParameter; - count = arc2polybezier(NULL, x1, y1, x2, y2, startAngle, sweepAngle); + count = arc2polybezier(NULL, x, y, width, height, startAngle, sweepAngle); if(count == 0) return Ok; @@ -323,7 +323,7 @@ GpStatus WINGDIPAPI GdipAddPathArc(GpPath *path, REAL x1, REAL y1, REAL x2, if(!points) return OutOfMemory; - arc2polybezier(points, x1, y1, x2, y2, startAngle, sweepAngle); + arc2polybezier(points, x, y, width, height, startAngle, sweepAngle); status = extend_current_figure(path, points, count, PathPointTypeBezier); diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 558eedc147f..c9eee5e96bb 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -451,6 +451,20 @@ static void test_arc(void) GpPath* path; GdipCreatePath(FillModeAlternate, &path); + + status = GdipAddPathArc(path, 100.0, 100.0, 1.0, 0.0, 0.0, 90.0); + expect(InvalidParameter, status); + + status = GdipAddPathArc(path, 100.0, 100.0, 0.0, 1.0, 0.0, 90.0); + expect(InvalidParameter, status); + + status = GdipAddPathArc(path, 100.0, 100.0, -40, 1.0, 0.0, 90.0); + expect(InvalidParameter, status); + + status = GdipAddPathArc(path, 100.0, 100.0, 1.0, -50.0, 0.0, 90.0); + expect(InvalidParameter, status); + + GdipResetPath(path); /* Exactly 90 degrees */ status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 90.0); expect(Ok, status); @@ -1263,21 +1277,8 @@ static void test_flatten2(void) status = GdipStartPathFigure(path); expect(Ok, status); - /* path seen in the wild that caused a stack overflow */ - status = GdipAddPathArc(path, -136.33, 20.00, 786.00, 786.00, -105.00, 30.00); - expect(Ok, status); - status = GdipAddPathArc(path, 256.67, 413.00, 0.00, 0.00, -75.00, -30.00); - expect(Ok, status); - status = GdipClosePathFigure(path); - expect(Ok, status); - - status = GdipFlattenPath(path, NULL, 1.0); - expect(Ok, status); - /* path seen in the wild that caused a stack overflow */ /* same path but redo with the manual points that caused a crash */ - status = GdipResetPath(path); - expect(Ok, status); status = GdipAddPathBezier(path, 154.950806, 33.391144, 221.586075, 15.536285, 291.747314, 15.536285, 358.382568, 33.391144); expect(Ok, status); status = GdipAddPathBezier(path, 256.666809, 412.999512, 256.666718, 412.999481, 256.666656, 412.999481, 256.666565, 412.999512); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3461
From: David Kahurani <k.kahurani(a)gmail.com> Signed-off-by: David Kahurani <k.kahurani(a)gmail.com> --- dlls/gdiplus/tests/graphicspath.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index c9eee5e96bb..b0ee9f41360 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -1263,16 +1263,7 @@ static void test_flatten(void) expect(Ok, status); ok_path(path, flattenquater_path, ARRAY_SIZE(flattenquater_path), FALSE); - GdipDeleteMatrix(m); - GdipDeletePath(path); -} - -static void test_flatten2(void) -{ - GpStatus status; - GpPath *path; - - status = GdipCreatePath(0, &path); + status = GdipResetPath(path); expect(Ok, status); status = GdipStartPathFigure(path); expect(Ok, status); @@ -1286,7 +1277,9 @@ static void test_flatten2(void) status = GdipClosePathFigure(path); expect(Ok, status); status = GdipFlattenPath(path, NULL, 1.0); + expect(Ok, status); + GdipDeleteMatrix(m); GdipDeletePath(path); } @@ -1972,7 +1965,6 @@ START_TEST(graphicspath) test_widen_cap(); test_isvisible(); test_empty_rect(); - test_flatten2(); GdiplusShutdown(gdiplusToken); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3461
This merge request was approved by Esme Povirk. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3461
participants (3)
-
David Kahurani -
David Kahurani (@kahurani) -
Esme Povirk (@madewokherd)