1 From 03a820b173ed1fdef6ff14b4468f5dbc02ff59be Mon Sep 17 00:00:00 2001
2 From: Heiko Lewin <heiko.lewin@worldiety.de>
3 Date: Tue, 15 Dec 2020 16:48:19 +0100
4 Subject: [PATCH] Fix mask usage in image-compositor
5
6 ---
7 src/cairo-image-compositor.c | 8 ++--
8 test/Makefile.sources | 1 +
9 test/bug-image-compositor.c | 39 ++++++++++++++++++++
10 4 files changed, 44 insertions(+), 4 deletions(-)
11 create mode 100644 test/bug-image-compositor.c
12
13 diff --git a/src/cairo-image-compositor.c b/src/cairo-image-compositor.c
14 index 79ad69f68..4f8aaed99 100644
15 --- a/src/cairo-image-compositor.c
16 +++ b/src/cairo-image-compositor.c
17 @@ -2610,14 +2610,14 @@ _inplace_src_spans (void *abstract_renderer, int y, int h,
18 unsigned num_spans)
19 {
20 cairo_image_span_renderer_t *r = abstract_renderer;
21 - uint8_t *m;
22 + uint8_t *m, *base = (uint8_t*)pixman_image_get_data(r->mask);
23 int x0;
24
25 if (num_spans == 0)
26 return CAIRO_STATUS_SUCCESS;
27
28 x0 = spans[0].x;
29 - m = r->_buf;
30 + m = base;
31 do {
32 int len = spans[1].x - spans[0].x;
33 if (len >= r->u.composite.run_length && spans[0].coverage == 0xff) {
34 @@ -2655,7 +2655,7 @@ _inplace_src_spans (void *abstract_renderer, int y, int h,
35 spans[0].x, y,
36 spans[1].x - spans[0].x, h);
37
38 - m = r->_buf;
39 + m = base;
40 x0 = spans[1].x;
41 } else if (spans[0].coverage == 0x0) {
42 if (spans[0].x != x0) {
43 @@ -2684,7 +2684,7 @@ _inplace_src_spans (void *abstract_renderer, int y, int h,
44 #endif
45 }
46
47 - m = r->_buf;
48 + m = base;
49 x0 = spans[1].x;
50 } else {
51 *m++ = spans[0].coverage;
52 diff --git a/test/Makefile.sources b/test/Makefile.sources
53 index 7eb73647f..86494348d 100644
54 --- a/test/Makefile.sources
55 +++ b/test/Makefile.sources
56 @@ -34,6 +34,7 @@ test_sources = \
57 bug-source-cu.c \
58 bug-extents.c \
59 bug-seams.c \
60 + bug-image-compositor.c \
61 caps.c \
62 checkerboard.c \
63 caps-joins.c \
64 diff --git a/test/bug-image-compositor.c b/test/bug-image-compositor.c
65 new file mode 100644
66 index 000000000..fc4fd370b
67 --- /dev/null
68 +++ b/test/bug-image-compositor.c
69 @@ -0,0 +1,39 @@
70 +#include "cairo-test.h"
71 +
72 +static cairo_test_status_t
73 +draw (cairo_t *cr, int width, int height)
74 +{
75 + cairo_set_source_rgb (cr, 0., 0., 0.);
76 + cairo_paint (cr);
77 +
78 + cairo_set_source_rgb (cr, 1., 1., 1.);
79 + cairo_set_line_width (cr, 1.);
80 +
81 + cairo_pattern_t *p = cairo_pattern_create_linear (0, 0, width, height);
82 + cairo_pattern_add_color_stop_rgb (p, 0, 0.99, 1, 1);
83 + cairo_pattern_add_color_stop_rgb (p, 1, 1, 1, 1);
84 + cairo_set_source (cr, p);
85 +
86 + cairo_move_to (cr, 0.5, -1);
87 + for (int i = 0; i < width; i+=3) {
88 + cairo_rel_line_to (cr, 2, 2);
89 + cairo_rel_line_to (cr, 1, -2);
90 + }
91 +
92 + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
93 + cairo_stroke (cr);
94 +
95 + cairo_pattern_destroy(p);
96 +
97 + return CAIRO_TEST_SUCCESS;
98 +}
99 +
100 +
101 +CAIRO_TEST (bug_image_compositor,
102 + "Crash in image-compositor",
103 + "stroke, stress", /* keywords */
104 + NULL, /* requirements */
105 + 10000, 1,
106 + NULL, draw)
107 +
108 +
109
110 --
111 GitLab
|