[cairo-commit] 4 commits - src/cairo-font-options.c src/cairo-ft-font.c src/cairoint.h src/cairo-surface.c
Behdad Esfahbod
behdad at kemper.freedesktop.org
Fri Jan 5 14:31:33 UTC 2018
src/cairo-font-options.c | 8 +++++++-
src/cairo-ft-font.c | 22 +++++++++++++++++++++-
src/cairo-surface.c | 1 +
src/cairoint.h | 3 +++
4 files changed, 32 insertions(+), 2 deletions(-)
New commits:
commit 37f9a5525da457226317d426e06c55d77da206c1
Author: Matthias Clasen <mclasen at redhat.com>
Date: Fri Jan 5 09:10:32 2018 -0500
Don't leak memory in font options
The cairo_font_options_t struct may now contain allocated
memory, so call fini whenever we are about to let go of an
embedded cairo_font_options_t struct.
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index e411172a..36672e93 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -191,6 +191,21 @@ typedef struct _cairo_ft_options {
unsigned int synth_flags;
} cairo_ft_options_t;
+static void
+_cairo_ft_options_init_copy (cairo_ft_options_t *options,
+ const cairo_ft_options_t *other)
+{
+ _cairo_font_options_init_copy (&options->base, &other->base);
+ options->load_flags = other->load_flags;
+ options->synth_flags = other->synth_flags;
+}
+
+static void
+_cairo_ft_options_fini (cairo_ft_options_t *options)
+{
+ _cairo_font_options_fini (&options->base);
+}
+
struct _cairo_ft_font_face {
cairo_font_face_t base;
@@ -3134,6 +3149,8 @@ _cairo_ft_font_face_destroy (void *abstract_face)
font_face->unscaled = NULL;
}
+ _cairo_ft_options_fini (&font_face->ft_options);
+
#if CAIRO_HAS_FC_FONT
if (font_face->pattern) {
FcPatternDestroy (font_face->pattern);
@@ -3287,7 +3304,7 @@ _cairo_ft_font_face_create (cairo_ft_unscaled_font_t *unscaled,
font_face->unscaled = unscaled;
_cairo_unscaled_font_reference (&unscaled->base);
- font_face->ft_options = *ft_options;
+ _cairo_ft_options_init_copy (&font_face->ft_options, ft_options);
if (unscaled->faces && unscaled->faces->unscaled == NULL) {
/* This "zombie" font_face (from _cairo_ft_font_face_destroy)
@@ -3534,6 +3551,7 @@ _cairo_ft_resolve_pattern (FcPattern *pattern,
_get_pattern_ft_options (resolved, &ft_options);
font_face = _cairo_ft_font_face_create (unscaled, &ft_options);
+ _cairo_ft_options_fini (&ft_options);
_cairo_unscaled_font_destroy (&unscaled->base);
FREE_RESOLVED:
@@ -3608,6 +3626,7 @@ cairo_ft_font_face_create_for_pattern (FcPattern *pattern)
_get_pattern_ft_options (pattern, &ft_options);
font_face = _cairo_ft_font_face_create (unscaled, &ft_options);
+ _cairo_ft_options_fini (&ft_options);
_cairo_unscaled_font_destroy (&unscaled->base);
return font_face;
commit 1f0b6707eab54ddbcc9ac0b68e0e483d33704644
Author: Matthias Clasen <mclasen at redhat.com>
Date: Fri Jan 5 09:09:01 2018 -0500
Add a _cairo_font_options_fini function
The variations member of cairo_font_options_t is allocated,
so we need to have a method to free it for cases where
the struct is embedded in larger structs, such as cairo_ft_options_t.
diff --git a/src/cairo-font-options.c b/src/cairo-font-options.c
index ea703423..de6ae951 100644
--- a/src/cairo-font-options.c
+++ b/src/cairo-font-options.c
@@ -154,6 +154,12 @@ cairo_font_options_copy (const cairo_font_options_t *original)
return options;
}
+void
+_cairo_font_options_fini (cairo_font_options_t *options)
+{
+ free (options->variations);
+}
+
/**
* cairo_font_options_destroy:
* @options: a #cairo_font_options_t
@@ -169,7 +175,7 @@ cairo_font_options_destroy (cairo_font_options_t *options)
if (cairo_font_options_status (options))
return;
- free (options->variations);
+ _cairo_font_options_fini (options);
free (options);
}
diff --git a/src/cairoint.h b/src/cairoint.h
index a51d2f93..051e4f80 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -881,6 +881,9 @@ _cairo_font_options_init_copy (cairo_font_options_t *options,
const cairo_font_options_t *other);
cairo_private void
+_cairo_font_options_fini (cairo_font_options_t *options);
+
+cairo_private void
_cairo_font_options_set_lcd_filter (cairo_font_options_t *options,
cairo_lcd_filter_t lcd_filter);
commit 17871c52eff5ae89af08b9deb4be36b6b6f4c0e3
Author: Matthias Clasen <mclasen at redhat.com>
Date: Thu Jan 4 23:25:09 2018 -0500
Don't leak patterns when compositing color glyphs
We were forgetting to free the pattern here.
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 18f63df3..5580b153 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -2654,6 +2654,7 @@ composite_one_color_glyph (cairo_surface_t *surface,
status = surface->backend->mask (surface, op, pattern, pattern, clip);
else
status = surface->backend->paint (surface, op, pattern, clip);
+ cairo_pattern_destroy (pattern);
}
return status;
commit 616fb7a9f2612f6cc3472542a70ba3e8ccf16584
Author: Matthias Clasen <mclasen at redhat.com>
Date: Thu Jan 4 20:56:59 2018 -0500
Fix a memory leak
cairo_ft_apply_variations was leaking the FT_MM_Var struct.
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index caa10153..e411172a 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -2362,6 +2362,7 @@ skip:
done:
free (coords);
free (current_coords);
+ free (ft_mm_var);
}
}
More information about the cairo-commit
mailing list