1 From 79ad01724161502e8d9d2bd384ff1f0174e5df6e Mon Sep 17 00:00:00 2001
2 From: Matthias Clasen <mclasen@redhat.com>
3 Date: Thu, 30 May 2019 07:30:55 -0400
4 Subject: [PATCH] Fix a thinko in composite_color_glyphs
6 We can't just move around the contents of the
7 passed-in string, we need to make a copy. This
8 was showing up as memory corruption in pango.
10 See https://gitlab.gnome.org/GNOME/pango/issues/346
12 src/cairo-surface.c | 10 ++++++++++
13 1 file changed, 10 insertions(+)
15 diff --git a/src/cairo-surface.c b/src/cairo-surface.c
16 index c30f84087..e112b660a 100644
17 --- a/src/cairo-surface.c
18 +++ b/src/cairo-surface.c
19 @@ -2820,6 +2820,7 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
20 const cairo_clip_t *clip)
22 cairo_int_status_t status;
23 + char *utf8_copy = NULL;
25 TRACE ((stderr, "%s\n", __FUNCTION__));
26 if (unlikely (surface->status))
27 @@ -2847,6 +2848,10 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
28 status = CAIRO_INT_STATUS_UNSUPPORTED;
30 if (_cairo_scaled_font_has_color_glyphs (scaled_font)) {
31 + utf8_copy = malloc (sizeof (char) * utf8_len);
32 + memcpy (utf8_copy, utf8, sizeof (char) * utf8_len);
35 status = composite_color_glyphs (surface, op,
37 (char *)utf8, &utf8_len,
38 @@ -2861,6 +2866,8 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
45 /* The logic here is duplicated in _cairo_analysis_surface show_glyphs and
46 * show_text_glyphs. Keep in synch. */
47 @@ -2918,6 +2925,9 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface,
54 return _cairo_surface_set_error (surface, status);