From 6967beb24ec605a4028ed4d0d065eefc5eb70ceb Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Wed, 26 Jun 2024 20:05:14 +0930 Subject: [PATCH 1/7] ps: fix max form size Fixes: #845 --- src/cairo-ps-surface.c | 4 ++-- test/mime-unique-id.c | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index 1d2bba20e..5421c39c9 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -3507,13 +3507,13 @@ _cairo_ps_surface_use_form (cairo_ps_surface_t *surface, if (surface->ps_level == CAIRO_PS_LEVEL_3) max_size = MAX_L3_FORM_DATA; else - max_size = MAX_L3_FORM_DATA; + max_size = MAX_L2_FORM_DATA; /* Don't add any more Forms if we exceed the form memory limit */ if (surface->total_form_size + params->approx_size > max_size) return CAIRO_INT_STATUS_UNSUPPORTED; - surface->total_form_size += params->approx_size > max_size; + surface->total_form_size += params->approx_size; unique_id = _cairo_malloc (source_key.unique_id_length); if (unique_id == NULL) return _cairo_error (CAIRO_STATUS_NO_MEMORY); diff --git a/test/mime-unique-id.c b/test/mime-unique-id.c index aab93164d..8d4a16133 100644 --- a/test/mime-unique-id.c +++ b/test/mime-unique-id.c @@ -79,10 +79,13 @@ * * If the size check fails, manually check the output and if the * surfaces are still embedded only once, update the expected sizes. + * + * Note: The PS2 output will embed the image more than once due to the + * lower MAX_L2_FORM_DATA for PS2 in cairo-ps-surface.c. */ -#define PS2_EXPECTED_SIZE 417510 -#define PS3_EXPECTED_SIZE 381554 -#define PDF_EXPECTED_SIZE 162923 +#define PS2_EXPECTED_SIZE 626926 +#define PS3_EXPECTED_SIZE 381555 +#define PDF_EXPECTED_SIZE 162692 #define SIZE_TOLERANCE 5000 static const char *png_filename = "romedalen.png"; From 2f671582eecf3a3af3f876e1749542b5dd5f301c Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Wed, 26 Jun 2024 20:21:25 +0930 Subject: [PATCH 2/7] Ensure face variables in cairo_stroker_t are initialized Fixes: #846 --- src/cairo-path-stroke.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c index 9ebeb6cd3..60f647eb7 100644 --- a/src/cairo-path-stroke.c +++ b/src/cairo-path-stroke.c @@ -162,6 +162,10 @@ _cairo_stroker_init (cairo_stroker_t *stroker, stroker->has_first_face = FALSE; stroker->has_initial_sub_path = FALSE; + /* Coverity complains these may be unitialized. */ + memset (&stroker->current_face, 0, sizeof (cairo_stroke_face_t)); + memset (&stroker->first_face, 0, sizeof (cairo_stroke_face_t)); + _cairo_stroker_dash_init (&stroker->dash, stroke_style); stroker->add_external_edge = NULL; From fff7b8f392e0b2793f2f96350ebdf00f27850aea Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Wed, 26 Jun 2024 20:25:56 +0930 Subject: [PATCH 3/7] Make Coverity happy Fixes: #847 --- src/cairo-pdf-interchange.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cairo-pdf-interchange.c b/src/cairo-pdf-interchange.c index 29d5c5d9c..720ce0d53 100644 --- a/src/cairo-pdf-interchange.c +++ b/src/cairo-pdf-interchange.c @@ -1959,6 +1959,8 @@ _cairo_pdf_interchange_tag_end (cairo_pdf_surface_t *surface, } else if (surface->paginated_mode == CAIRO_PAGINATED_MODE_RENDER) { status = _cairo_tag_stack_pop (&ic->render_tag_stack, name, &elem); + } else { + ASSERT_NOT_REACHED; } if (unlikely (status)) return status; From c235bc4dee40010b85f893044d5ff513d3766803 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Wed, 26 Jun 2024 20:28:54 +0930 Subject: [PATCH 4/7] Fix bug in cairo-trace when writing A8 images Fixes: #848 --- util/cairo-trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c index 1bdb07591..8bdb3f881 100644 --- a/util/cairo-trace/trace.c +++ b/util/cairo-trace/trace.c @@ -1742,7 +1742,7 @@ _emit_image (cairo_surface_t *image, break; case CAIRO_FORMAT_A8: for (row = height; row--; ) { - _write_data (&stream, rowdata, width); + _write_data (&stream, data, width); data += stride; } break; From 545073d7edb28f6e58dd120b943a37af6253b5c8 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Wed, 26 Jun 2024 20:39:51 +0930 Subject: [PATCH 5/7] Ensure extent_y_scale is initialized Fixes: #849 --- src/cairo-ft-font.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c index 360f03fda..b5d08ee1b 100644 --- a/src/cairo-ft-font.c +++ b/src/cairo-ft-font.c @@ -2808,8 +2808,8 @@ _cairo_ft_scaled_glyph_init_record_colr_v1_glyph (cairo_ft_scaled_font_t *scaled /* Copied from cairo-user-font.c */ cairo_matrix_t extent_scale; - double extent_x_scale; - double extent_y_scale; + double extent_x_scale = 1.0; + double extent_y_scale = 1.0; double snap_x_scale; double snap_y_scale; double fixed_scale, x_scale, y_scale; From c8ce9f1900a4a36434c1d959ed08668746436081 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Wed, 26 Jun 2024 20:43:32 +0930 Subject: [PATCH 6/7] Check return value of _cairo_boxes_copy_to_clip() Fixes: #850 --- src/cairo-clip-boxes.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cairo-clip-boxes.c b/src/cairo-clip-boxes.c index 3ebcd509c..777b7ddc1 100644 --- a/src/cairo-clip-boxes.c +++ b/src/cairo-clip-boxes.c @@ -318,7 +318,10 @@ _cairo_clip_intersect_boxes (cairo_clip_t *clip, goto out; } - _cairo_boxes_copy_to_clip (boxes, clip); + if (!_cairo_boxes_copy_to_clip (boxes, clip)) { + clip = _cairo_clip_set_all_clipped (clip); + goto out; + } _cairo_boxes_extents (boxes, &limits); From 64301c61058ca1c1b244c8b1f6ca23502386fcbb Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Wed, 26 Jun 2024 21:00:34 +0930 Subject: [PATCH 7/7] doc: Ensure @ in "@cairo:" is escaped when referring the the font family name Fixes: #851 --- src/cairo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cairo.c b/src/cairo.c index 00521f264..78c60df5c 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -3013,11 +3013,11 @@ cairo_tag_end (cairo_t *cr, const char *tag_name) * "sans-serif", "cursive", "fantasy", "monospace"), are likely to * work as expected. * - * If @family starts with the string "@cairo:", or if no native font + * If @family starts with the string "\@cairo:", or if no native font * backends are compiled in, cairo will use an internal font family. * The internal font family recognizes many modifiers in the @family * string, most notably, it recognizes the string "monospace". That is, - * the family name "@cairo:monospace" will use the monospace version of + * the family name "\@cairo:monospace" will use the monospace version of * the internal font family. * * For "real" font selection, see the font-backend-specific