|
|
38a2ac |
From 40e9d1a0a69f01b55b4fa131bc253c7c09a0ae91 Mon Sep 17 00:00:00 2001
|
|
|
38a2ac |
From: Heiko Lewin <heiko.lewin@worldiety.de>
|
|
|
38a2ac |
Date: Tue, 15 Dec 2020 16:48:19 +0100
|
|
|
38a2ac |
Subject: [PATCH 1/2] Fix mask usage in image-compositor
|
|
|
38a2ac |
|
|
|
38a2ac |
---
|
|
|
38a2ac |
src/cairo-image-compositor.c | 8 ++--
|
|
|
38a2ac |
test/Makefile.sources | 1 +
|
|
|
38a2ac |
test/bug-image-compositor.c | 39 ++++++++++++++++++++
|
|
|
38a2ac |
test/reference/bug-image-compositor.ref.png | Bin 0 -> 185 bytes
|
|
|
38a2ac |
4 files changed, 44 insertions(+), 4 deletions(-)
|
|
|
38a2ac |
create mode 100644 test/bug-image-compositor.c
|
|
|
38a2ac |
create mode 100644 test/reference/bug-image-compositor.ref.png
|
|
|
38a2ac |
|
|
|
38a2ac |
diff --git a/src/cairo-image-compositor.c b/src/cairo-image-compositor.c
|
|
|
38a2ac |
index 122a8ca42..b20e2ec78 100644
|
|
|
38a2ac |
--- a/src/cairo-image-compositor.c
|
|
|
38a2ac |
+++ b/src/cairo-image-compositor.c
|
|
|
38a2ac |
@@ -2601,14 +2601,14 @@ _inplace_src_spans (void *abstract_renderer, int y, int h,
|
|
|
38a2ac |
unsigned num_spans)
|
|
|
38a2ac |
{
|
|
|
38a2ac |
cairo_image_span_renderer_t *r = abstract_renderer;
|
|
|
38a2ac |
- uint8_t *m;
|
|
|
38a2ac |
+ uint8_t *m, *base = (uint8_t*)pixman_image_get_data(r->mask);
|
|
|
38a2ac |
int x0;
|
|
|
38a2ac |
|
|
|
38a2ac |
if (num_spans == 0)
|
|
|
38a2ac |
return CAIRO_STATUS_SUCCESS;
|
|
|
38a2ac |
|
|
|
38a2ac |
x0 = spans[0].x;
|
|
|
38a2ac |
- m = r->_buf;
|
|
|
38a2ac |
+ m = base;
|
|
|
38a2ac |
do {
|
|
|
38a2ac |
int len = spans[1].x - spans[0].x;
|
|
|
38a2ac |
if (len >= r->u.composite.run_length && spans[0].coverage == 0xff) {
|
|
|
38a2ac |
@@ -2646,7 +2646,7 @@ _inplace_src_spans (void *abstract_renderer, int y, int h,
|
|
|
38a2ac |
spans[0].x, y,
|
|
|
38a2ac |
spans[1].x - spans[0].x, h);
|
|
|
38a2ac |
|
|
|
38a2ac |
- m = r->_buf;
|
|
|
38a2ac |
+ m = base;
|
|
|
38a2ac |
x0 = spans[1].x;
|
|
|
38a2ac |
} else if (spans[0].coverage == 0x0) {
|
|
|
38a2ac |
if (spans[0].x != x0) {
|
|
|
38a2ac |
@@ -2675,7 +2675,7 @@ _inplace_src_spans (void *abstract_renderer, int y, int h,
|
|
|
38a2ac |
#endif
|
|
|
38a2ac |
}
|
|
|
38a2ac |
|
|
|
38a2ac |
- m = r->_buf;
|
|
|
38a2ac |
+ m = base;
|
|
|
38a2ac |
x0 = spans[1].x;
|
|
|
38a2ac |
} else {
|
|
|
38a2ac |
*m++ = spans[0].coverage;
|
|
|
38a2ac |
diff --git a/test/Makefile.sources b/test/Makefile.sources
|
|
|
38a2ac |
index c47131faf..86fd53d15 100644
|
|
|
38a2ac |
--- a/test/Makefile.sources
|
|
|
38a2ac |
+++ b/test/Makefile.sources
|
|
|
38a2ac |
@@ -33,6 +33,7 @@ test_sources = \
|
|
|
38a2ac |
bug-source-cu.c \
|
|
|
38a2ac |
bug-extents.c \
|
|
|
38a2ac |
bug-seams.c \
|
|
|
38a2ac |
+ bug-image-compositor.c \
|
|
|
38a2ac |
caps.c \
|
|
|
38a2ac |
checkerboard.c \
|
|
|
38a2ac |
caps-joins.c \
|
|
|
38a2ac |
diff --git a/test/bug-image-compositor.c b/test/bug-image-compositor.c
|
|
|
38a2ac |
new file mode 100644
|
|
|
38a2ac |
index 000000000..fc4fd370b
|
|
|
38a2ac |
--- /dev/null
|
|
|
38a2ac |
+++ b/test/bug-image-compositor.c
|
|
|
38a2ac |
@@ -0,0 +1,39 @@
|
|
|
38a2ac |
+#include "cairo-test.h"
|
|
|
38a2ac |
+
|
|
|
38a2ac |
+static cairo_test_status_t
|
|
|
38a2ac |
+draw (cairo_t *cr, int width, int height)
|
|
|
38a2ac |
+{
|
|
|
38a2ac |
+ cairo_set_source_rgb (cr, 0., 0., 0.);
|
|
|
38a2ac |
+ cairo_paint (cr);
|
|
|
38a2ac |
+
|
|
|
38a2ac |
+ cairo_set_source_rgb (cr, 1., 1., 1.);
|
|
|
38a2ac |
+ cairo_set_line_width (cr, 1.);
|
|
|
38a2ac |
+
|
|
|
38a2ac |
+ cairo_pattern_t *p = cairo_pattern_create_linear (0, 0, width, height);
|
|
|
38a2ac |
+ cairo_pattern_add_color_stop_rgb (p, 0, 0.99, 1, 1);
|
|
|
38a2ac |
+ cairo_pattern_add_color_stop_rgb (p, 1, 1, 1, 1);
|
|
|
38a2ac |
+ cairo_set_source (cr, p);
|
|
|
38a2ac |
+
|
|
|
38a2ac |
+ cairo_move_to (cr, 0.5, -1);
|
|
|
38a2ac |
+ for (int i = 0; i < width; i+=3) {
|
|
|
38a2ac |
+ cairo_rel_line_to (cr, 2, 2);
|
|
|
38a2ac |
+ cairo_rel_line_to (cr, 1, -2);
|
|
|
38a2ac |
+ }
|
|
|
38a2ac |
+
|
|
|
38a2ac |
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
|
|
|
38a2ac |
+ cairo_stroke (cr);
|
|
|
38a2ac |
+
|
|
|
38a2ac |
+ cairo_pattern_destroy(p);
|
|
|
38a2ac |
+
|
|
|
38a2ac |
+ return CAIRO_TEST_SUCCESS;
|
|
|
38a2ac |
+}
|
|
|
38a2ac |
+
|
|
|
38a2ac |
+
|
|
|
38a2ac |
+CAIRO_TEST (bug_image_compositor,
|
|
|
38a2ac |
+ "Crash in image-compositor",
|
|
|
38a2ac |
+ "stroke, stress", /* keywords */
|
|
|
38a2ac |
+ NULL, /* requirements */
|
|
|
38a2ac |
+ 10000, 1,
|
|
|
38a2ac |
+ NULL, draw)
|
|
|
38a2ac |
+
|
|
|
38a2ac |
+
|
|
|
38a2ac |
diff --git a/test/reference/bug-image-compositor.ref.png b/test/reference/bug-image-compositor.ref.png
|
|
|
38a2ac |
new file mode 100644
|
|
|
38a2ac |
index 0000000000000000000000000000000000000000..939f659d2c8620e9927a3a79f5e96fb639c418be
|
|
|
38a2ac |
GIT binary patch
|
|
|
38a2ac |
literal 185
|
|
|
38a2ac |
zcmeAS@N?(olHy`uVBq!ia0y~yP!|BQ89A7M<o7+wF+hqf$=lt9;Xep2*t>i(P$bXO
|
|
|
38a2ac |
z#WAE}&f8-f1se=_SPWL_NSx=C)BnJ0eBr6Z%1egFEOv(*t#+|{>X&v^RS7GQe(vez
|
|
|
38a2ac |
lf)$wgmAfM(p2Sx&&i!{gWy)N&qd=P(JYD@<);T3K0RWsgHuC@g
|
|
|
38a2ac |
|
|
|
38a2ac |
literal 0
|
|
|
38a2ac |
HcmV?d00001
|
|
|
38a2ac |
|
|
|
38a2ac |
--
|
|
|
38a2ac |
2.34.1
|
|
|
38a2ac |
|
|
|
38a2ac |
|
|
|
38a2ac |
From afc23bfdc3c2597b9fe0ee34b9b4bfa47fa03698 Mon Sep 17 00:00:00 2001
|
|
|
38a2ac |
From: Heiko Lewin <heiko.lewin@worldiety.de>
|
|
|
38a2ac |
Date: Tue, 15 Dec 2020 17:14:18 +0100
|
|
|
38a2ac |
Subject: [PATCH 2/2] Minor cleanups
|
|
|
38a2ac |
|
|
|
38a2ac |
---
|
|
|
38a2ac |
test/bug-image-compositor.c | 33 ++++++++++++++++++++++++++++++---
|
|
|
38a2ac |
1 file changed, 30 insertions(+), 3 deletions(-)
|
|
|
38a2ac |
|
|
|
38a2ac |
diff --git a/test/bug-image-compositor.c b/test/bug-image-compositor.c
|
|
|
38a2ac |
index fc4fd370b..304ea089c 100644
|
|
|
38a2ac |
--- a/test/bug-image-compositor.c
|
|
|
38a2ac |
+++ b/test/bug-image-compositor.c
|
|
|
38a2ac |
@@ -1,5 +1,34 @@
|
|
|
38a2ac |
+/*
|
|
|
38a2ac |
+ * Copyright © 2020 Uli Schlachter, Heiko Lewin
|
|
|
38a2ac |
+ *
|
|
|
38a2ac |
+ * Permission is hereby granted, free of charge, to any person
|
|
|
38a2ac |
+ * obtaining a copy of this software and associated documentation
|
|
|
38a2ac |
+ * files (the "Software"), to deal in the Software without
|
|
|
38a2ac |
+ * restriction, including without limitation the rights to use, copy,
|
|
|
38a2ac |
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
38a2ac |
+ * of the Software, and to permit persons to whom the Software is
|
|
|
38a2ac |
+ * furnished to do so, subject to the following conditions:
|
|
|
38a2ac |
+ *
|
|
|
38a2ac |
+ * The above copyright notice and this permission notice shall be
|
|
|
38a2ac |
+ * included in all copies or substantial portions of the Software.
|
|
|
38a2ac |
+ *
|
|
|
38a2ac |
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
38a2ac |
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
38a2ac |
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
38a2ac |
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
38a2ac |
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
38a2ac |
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
38a2ac |
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
38a2ac |
+ * SOFTWARE.
|
|
|
38a2ac |
+ *
|
|
|
38a2ac |
+ * Author: Uli Schlachter <psychon@znc.in>
|
|
|
38a2ac |
+ * Author: Heiko Lewin <hlewin@gmx.de>
|
|
|
38a2ac |
+ */
|
|
|
38a2ac |
#include "cairo-test.h"
|
|
|
38a2ac |
|
|
|
38a2ac |
+
|
|
|
38a2ac |
+/* This test reproduces an overflow of a mask-buffer in cairo-image-compositor.c */
|
|
|
38a2ac |
+
|
|
|
38a2ac |
static cairo_test_status_t
|
|
|
38a2ac |
draw (cairo_t *cr, int width, int height)
|
|
|
38a2ac |
{
|
|
|
38a2ac |
@@ -13,6 +42,7 @@ draw (cairo_t *cr, int width, int height)
|
|
|
38a2ac |
cairo_pattern_add_color_stop_rgb (p, 0, 0.99, 1, 1);
|
|
|
38a2ac |
cairo_pattern_add_color_stop_rgb (p, 1, 1, 1, 1);
|
|
|
38a2ac |
cairo_set_source (cr, p);
|
|
|
38a2ac |
+ cairo_pattern_destroy(p);
|
|
|
38a2ac |
|
|
|
38a2ac |
cairo_move_to (cr, 0.5, -1);
|
|
|
38a2ac |
for (int i = 0; i < width; i+=3) {
|
|
|
38a2ac |
@@ -23,8 +53,6 @@ draw (cairo_t *cr, int width, int height)
|
|
|
38a2ac |
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
|
|
|
38a2ac |
cairo_stroke (cr);
|
|
|
38a2ac |
|
|
|
38a2ac |
- cairo_pattern_destroy(p);
|
|
|
38a2ac |
-
|
|
|
38a2ac |
return CAIRO_TEST_SUCCESS;
|
|
|
38a2ac |
}
|
|
|
38a2ac |
|
|
|
38a2ac |
@@ -36,4 +64,3 @@ CAIRO_TEST (bug_image_compositor,
|
|
|
38a2ac |
10000, 1,
|
|
|
38a2ac |
NULL, draw)
|
|
|
38a2ac |
|
|
|
38a2ac |
-
|
|
|
38a2ac |
--
|
|
|
38a2ac |
2.34.1
|
|
|
38a2ac |
|