Free color glyphs hash table when SVG surface is destroyed

Signed-off-by: Raman Varabets <gitlab-20240601-da2ef10c@cyborgize.sg>
This commit is contained in:
Raman Varabets 2024-06-02 19:35:06 +08:00
parent d53079cfcc
commit bf652edbf7

View file

@ -147,6 +147,18 @@ _cairo_svg_source_surface_pluck (void *entry, void *closure)
free (source_surface);
}
static void
_cairo_svg_color_glyph_pluck (void *entry, void *closure)
{
cairo_svg_color_glyph_t *glyph_entry = entry;
cairo_hash_table_t *patterns = closure;
_cairo_hash_table_remove (patterns, &glyph_entry->base);
cairo_scaled_font_destroy (glyph_entry->scaled_font);
free (glyph_entry);
}
static void
_cairo_svg_paint_init_key (cairo_svg_paint_t *paint)
{
@ -1744,6 +1756,11 @@ _cairo_svg_surface_finish (void *abstract_surface)
_cairo_hash_table_foreach (surface->source_surfaces, _cairo_svg_source_surface_pluck, surface->source_surfaces);
_cairo_hash_table_destroy (surface->source_surfaces);
_cairo_hash_table_foreach (surface->color_glyphs,
_cairo_svg_color_glyph_pluck,
surface->color_glyphs);
_cairo_hash_table_destroy (surface->color_glyphs);
status = _cairo_svg_document_destroy (surface->document);
if (final_status == CAIRO_STATUS_SUCCESS) {
final_status = status;