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@gmail.com
-- v3: gdiplus: Move Flatten() tests into the same function gdiplus: Reject zero-width/zero-height rectangles
From: David Kahurani k.kahurani@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55351 Signed-off-by: David Kahurani k.kahurani@gmail.com --- dlls/gdiplus/graphicspath.c | 20 ++++++++++---------- dlls/gdiplus/tests/graphicspath.c | 25 ++++++++++++++----------- 2 files changed, 24 insertions(+), 21 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..f03408722ed 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,17 +1277,6 @@ 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);
From: David Kahurani k.kahurani@gmail.com
Signed-off-by: David Kahurani k.kahurani@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 f03408722ed..de9b0cedef3 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); @@ -1288,7 +1279,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); }
@@ -1974,7 +1967,6 @@ START_TEST(graphicspath) test_widen_cap(); test_isvisible(); test_empty_rect(); - test_flatten2();
GdiplusShutdown(gdiplusToken); }
On Mon Jul 31 16:46:17 2023 +0000, David Kahurani wrote:
changed this line in [version 3 of the diff](/wine/wine/-/merge_requests/3461/diffs?diff_id=60270&start_sha=ef66d8bbaa69549302a030c323f860b741df94a1#6a24b35dd990fb1e969a07d96617e98ecefa4da2_1262_1271)
I addressed all your comments :-). Pushed a new version.
Actually, you're right and I was wrong about the width/height. Negative values are also rejected.