[cairo-commit] 2 commits - src/cairo-tor22-scan-converter.c test/bug-75705.c test/Makefile.sources test/reference

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 10 15:03:34 UTC 2019


 src/cairo-tor22-scan-converter.c |    7 +++++--
 test/Makefile.sources            |    1 +
 test/bug-75705.c                 |   32 ++++++++++++++++++++++++++++++++
 test/reference/bug-75705.ref.png |binary
 4 files changed, 38 insertions(+), 2 deletions(-)

New commits:
commit dfe3aa6d88ad548b729cf8e5b5ff9d80fbb0e412
Author: Antony Lee <anntzer.lee at gmail.com>
Date:   Mon Feb 11 08:48:56 2019 +0100

    Fix off-by-one bug in tor22-scan-converter.
    
    This makes the implementation in tor22-scan-converter match the one in
    tor-scan-converter.

diff --git a/src/cairo-tor22-scan-converter.c b/src/cairo-tor22-scan-converter.c
index bf44742b0..79c858e4e 100644
--- a/src/cairo-tor22-scan-converter.c
+++ b/src/cairo-tor22-scan-converter.c
@@ -1287,12 +1287,15 @@ glitter_scan_converter_reset(
 			     int xmax, int ymax)
 {
     glitter_status_t status;
+    int max_num_spans;
 
     converter->xmin = 0; converter->xmax = 0;
     converter->ymin = 0; converter->ymax = 0;
 
-    if (xmax - xmin > ARRAY_LENGTH(converter->spans_embedded)) {
-	converter->spans = _cairo_malloc_ab (xmax - xmin,
+    max_num_spans = xmax - xmin + 1;
+
+    if (max_num_spans > ARRAY_LENGTH(converter->spans_embedded)) {
+	converter->spans = _cairo_malloc_ab (max_num_spans,
 					     sizeof (cairo_half_open_span_t));
 	if (unlikely (converter->spans == NULL))
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
commit 82a2477a4a305cdcd8f331e6539db8742e0829e6
Author: Massimo Valentini <mvalentini at src.gnome.org>
Date:   Fri Jan 16 12:56:04 2015 +0100

    add a test to exercise tor22 spans allocation code path

diff --git a/test/Makefile.sources b/test/Makefile.sources
index c47131faf..3451125f9 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -26,6 +26,7 @@ test_sources = \
 	bilevel-image.c					\
 	bug-40410.c					\
 	bug-51910.c					\
+	bug-75705.c					\
 	bug-84115.c					\
 	bug-bo-rectangular.c				\
 	bug-bo-collins.c				\
diff --git a/test/bug-75705.c b/test/bug-75705.c
new file mode 100644
index 000000000..e140ff993
--- /dev/null
+++ b/test/bug-75705.c
@@ -0,0 +1,32 @@
+#include "cairo-test.h"
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    double dsh[2] = {1,3};
+
+    cairo_set_source_rgba (cr, 0, 0, 0, 1);
+    cairo_paint (cr);
+
+    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+
+    cairo_move_to (cr, 3, 3);
+    /* struct glitter_scan_converter spans_embedded array size is 64 */
+    cairo_line_to (cr, 65+3, 3);
+
+    cairo_set_antialias (cr, CAIRO_ANTIALIAS_FAST);
+    cairo_set_tolerance (cr, 1);
+
+    cairo_set_dash (cr, dsh, 2, 0);
+    cairo_set_line_width (cr, 2);
+
+    cairo_stroke (cr);
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (bug_75705,
+	    "Bug 75705 (exercise tor22-scan-converter)",
+	    "dash, stroke, antialias", /* keywords */
+	    NULL, /* requirements */
+	    72, 8,
+	    NULL, draw)
diff --git a/test/reference/bug-75705.ref.png b/test/reference/bug-75705.ref.png
new file mode 100644
index 000000000..c0ac5ff64
Binary files /dev/null and b/test/reference/bug-75705.ref.png differ


More information about the cairo-commit mailing list