[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.
This commit is contained in:
Chris Wilson 2007-05-12 15:32:34 +01:00
parent fcd1076bcf
commit b63b32958e

View file

@ -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;
}
}
}