From b63b32958e690409448ddc14e19b1856b9ef555a Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 12 May 2007 15:32:34 +0100 Subject: [PATCH] [cairo-scaled-font-subsets] Destroy the parent and subfont on error. If we fail to create the sub font destroy the local reference to the parent font and if we fail to insert the sub font into the hash table, destroy the newly create sub font. --- src/cairo-scaled-font-subsets.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c index 1846db85c..53ea5afb4 100644 --- a/src/cairo-scaled-font-subsets.c +++ b/src/cairo-scaled-font-subsets.c @@ -553,13 +553,17 @@ _cairo_scaled_font_subsets_map_glyph (cairo_scaled_font_subsets_t *subsets, max_glyphs, subset_glyph->is_scaled, subset_glyph->is_composite); - if (sub_font == NULL) + if (sub_font == NULL) { + cairo_scaled_font_destroy (unscaled_font); return CAIRO_STATUS_NO_MEMORY; + } status = _cairo_hash_table_insert (subsets->unscaled_sub_fonts, &sub_font->base); - if (status) + if (status) { + _cairo_sub_font_destroy (sub_font); return status; + } } } else { /* No path available. Add to scaled subset. */ @@ -581,13 +585,17 @@ _cairo_scaled_font_subsets_map_glyph (cairo_scaled_font_subsets_t *subsets, max_glyphs, subset_glyph->is_scaled, subset_glyph->is_composite); - if (sub_font == NULL) + if (sub_font == NULL) { + cairo_scaled_font_destroy (scaled_font); return CAIRO_STATUS_NO_MEMORY; + } status = _cairo_hash_table_insert (subsets->scaled_sub_fonts, &sub_font->base); - if (status) + if (status) { + _cairo_sub_font_destroy (sub_font); return status; + } } }