File 0003-d2d1-tests-Avoid-out-of-bounds-access-when-comparing.patch of Package wine
From 6d9580332c35426b40653945ebd4f6ab98edecac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Sun, 2 Jan 2022 22:40:46 +0100
Subject: [PATCH 03/10] d2d1/tests: Avoid out-of-bounds access when comparing
segments
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In case real and expected segment count differ, don't compare the
segment type/position for extra segments.
Signed-off-by: Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de>
---
dlls/d2d1/tests/d2d1.c | 44 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index efa4bf488e1..3b7c45357ae 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -1248,6 +1248,7 @@ static void geometry_sink_check_(unsigned int line, const struct geometry_sink *
const struct expected_geometry_figure *expected_figure;
const struct geometry_figure *figure;
unsigned int i, j;
+ unsigned int segment_count;
BOOL match;
ok_(__FILE__, line)(sink->fill_mode == fill_mode,
@@ -1276,7 +1277,10 @@ static void geometry_sink_check_(unsigned int line, const struct geometry_sink *
"Got unexpected figure %u segment count %u, expected %u.\n",
i, figure->segment_count, expected_figure->segment_count);
- for (j = 0; j < figure->segment_count; ++j)
+ segment_count = expected_figure->segment_count < figure->segment_count ?
+ expected_figure->segment_count : figure->segment_count;
+
+ for (j = 0; j < segment_count; ++j)
{
expected_segment = &expected_figure->segments[j];
segment = &figure->segments[j];
@@ -1315,6 +1319,44 @@ static void geometry_sink_check_(unsigned int line, const struct geometry_sink *
break;
}
}
+
+ for (j = segment_count; j < expected_figure->segment_count; ++j)
+ {
+ segment = &expected_figure->segments[j];
+ switch (segment->type)
+ {
+ case SEGMENT_LINE:
+ ok_(__FILE__, line)(FALSE, "Missing figure %u segment %u {%.8e, %.8e}.\n",
+ i, j, segment->u.line.x, segment->u.line.y);
+ break;
+ case SEGMENT_BEZIER:
+ ok_(__FILE__, line)(FALSE, "Missing figure %u segment %u "
+ "{%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}\n",
+ i, j, segment->u.bezier.point1.x, segment->u.bezier.point1.y,
+ segment->u.bezier.point2.x, segment->u.bezier.point2.y,
+ segment->u.bezier.point3.x, segment->u.bezier.point3.y);
+ break;
+ }
+ }
+
+ for (j = segment_count; j < figure->segment_count; ++j)
+ {
+ segment = &figure->segments[j];
+ switch (segment->type)
+ {
+ case SEGMENT_LINE:
+ ok_(__FILE__, line)(FALSE, "Got unexpected figure %u segment %u {%.8e, %.8e}.\n",
+ i, j, segment->u.line.x, segment->u.line.y);
+ break;
+ case SEGMENT_BEZIER:
+ ok_(__FILE__, line)(FALSE, "Got unexpected figure %u segment %u "
+ "{%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}\n",
+ i, j, segment->u.bezier.point1.x, segment->u.bezier.point1.y,
+ segment->u.bezier.point2.x, segment->u.bezier.point2.y,
+ segment->u.bezier.point3.x, segment->u.bezier.point3.y);
+ break;
+ }
+ }
}
}
--
2.34.1