Fix a thinko in composite_color_glyphs

This commit is contained in:
Kalev Lember 2019-06-03 15:09:01 +02:00
parent 1a5f0205a7
commit 154f1316da
2 changed files with 63 additions and 1 deletions

View File

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

View File

@ -11,7 +11,7 @@
Name: cairo Name: cairo
Version: 1.16.0 Version: 1.16.0
Release: 4%{?dist} Release: 5%{?dist}
Summary: A 2D graphics library Summary: A 2D graphics library
License: LGPLv2 or MPLv1.1 License: LGPLv2 or MPLv1.1
@ -26,6 +26,9 @@ Patch4: 0001-Set-default-LCD-filter-to-FreeType-s-default.patch
# https://gitlab.freedesktop.org/cairo/cairo/merge_requests/5 # https://gitlab.freedesktop.org/cairo/cairo/merge_requests/5
Patch5: 0001-ft-Use-FT_Done_MM_Var-instead-of-free-when-available.patch Patch5: 0001-ft-Use-FT_Done_MM_Var-instead-of-free-when-available.patch
# https://github.com/matthiasclasen/cairo/commit/79ad01724161502e8d9d2bd384ff1f0174e5df6e
Patch6: cairo-composite_color_glyphs.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: pkgconfig BuildRequires: pkgconfig
BuildRequires: libXrender-devel BuildRequires: libXrender-devel
@ -176,6 +179,9 @@ find $RPM_BUILD_ROOT -name '*.la' -delete
%{_libdir}/cairo/ %{_libdir}/cairo/
%changelog %changelog
* Mon Jun 03 2019 Kalev Lember <klember@redhat.com> - 1.16.0-5
- Fix a thinko in composite_color_glyphs
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.16.0-4 * Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.16.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild