From: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> Fixes a regression introduced by 9bc6f004ceccf3963584a4f7f4681b5c0578c214, which broke when REGION_CreateEdgeTable overflowed. Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> --- dlls/gdi32/region.c | 2 +- dlls/gdi32/tests/clipping.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dlls/gdi32/region.c b/dlls/gdi32/region.c index 893b6d6f4d3..878b73f8c94 100644 --- a/dlls/gdi32/region.c +++ b/dlls/gdi32/region.c @@ -2742,7 +2742,7 @@ HRGN create_polypolygon_region( const POINT *Pts, const INT *Count, INT nbpolygo nb_points = REGION_CreateEdgeTable( Count, nbpolygons, Pts, &ET, pETEs, &SLLBlock, clip_rect ); if ((obj = alloc_region( nb_points / 2 ))) { - scan_convert( obj, &ET, mode, clip_rect ); + if (nb_points) scan_convert( obj, &ET, mode, clip_rect ); if (!(hrgn = alloc_gdi_handle( obj, OBJ_REGION, ®ion_funcs ))) free_region( obj ); diff --git a/dlls/gdi32/tests/clipping.c b/dlls/gdi32/tests/clipping.c index 015157522da..484430b0cb9 100644 --- a/dlls/gdi32/tests/clipping.c +++ b/dlls/gdi32/tests/clipping.c @@ -513,8 +513,10 @@ static void test_CreatePolyPolygonRgn(void) POINT points_mixed[] = { {0, 0}, {0, 0}, {0, 0}, {6, 6}, {6, 6}, {6, 6} }; POINT points_six[] = { {6, 6}, {6, 6}, {6, 6} }; POINT points_line[] = { {1, 0}, {11, 0}, {21, 0}}; + POINT points_overflow[] = { {0, 0}, {1, 0}, {0, 0x80000000} }; INT counts_single_poly[] = { 3 }; INT counts_two_poly[] = { 3, 3 }; + INT counts_overflow[] = { ARRAY_SIZE(points_overflow) }; int ret; RECT rect; @@ -543,6 +545,13 @@ static void test_CreatePolyPolygonRgn(void) ret = GetRgnBox(region, &rect); ok (ret == NULLREGION, "Expected NULLREGION, got %d\n", ret); DeleteObject(region); + + /* Test with points that overflow the edge table */ + region = CreatePolyPolygonRgn(points_overflow, counts_overflow, ARRAY_SIZE(counts_overflow), ALTERNATE); + ok (region != NULL, "region must not be NULL\n"); + ret = GetRgnBox(region, &rect); + ok (ret == NULLREGION, "Expected NULLREGION, got %d\n", ret); + DeleteObject(region); } START_TEST(clipping) -- 2.23.0