mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 20:28:02 +02:00
Fix font options leak in cairo-surface.c
When calling cairo_surface_get_font_options(), a font options instance is allocated for the surface. Normally, this just initialised some otherwise uninitialised fields in cairo_surface_t. Since commit67eeed44, cairo_font_options_t can contain an extra allocation for a custom palette. Since commitedf9497c3a, cairo_font_options_t can contain an extra allocation for a string. Before these commit, font options could just be dropped, but now they need to be freed. This commit makes cairo_surface_destroy() finish the contained font options if they were initialised. I didn't manage to produce a self-contained test case for this leak. I found it by just looking at the code. However, I found a way to force a leak: By adding options->variations=strdtup("slnt=0,wght=400,wdth=100"); to the end of _cairo_font_options_init_default(), all font option instances now cause a leak unless they are finished. With this extra change, this commit fixes a memory leak that is simply caused by calling cairo_surface_get_font_options(). Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
7bf743a92f
commit
4c1987b0f0
1 changed files with 3 additions and 0 deletions
|
|
@ -983,6 +983,9 @@ cairo_surface_destroy (cairo_surface_t *surface)
|
|||
if (surface->owns_device)
|
||||
cairo_device_destroy (surface->device);
|
||||
|
||||
if (surface->has_font_options)
|
||||
_cairo_font_options_fini (&surface->font_options);
|
||||
|
||||
assert (surface->snapshot_of == NULL);
|
||||
assert (! _cairo_surface_has_snapshots (surface));
|
||||
/* paranoid check that nobody took a reference whilst finishing */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue