diff options
author | Uli Schlachter <psychon@znc.in> | 2023-09-17 10:00:51 +0200 |
---|---|---|
committer | Uli Schlachter <psychon@znc.in> | 2023-09-17 10:00:51 +0200 |
commit | 06864022c88d631d0c54b0b6756b157dbe30275c (patch) | |
tree | fb147f9d764c852e7717cb685a9a30a1dec1fe45 | |
parent | 29087868cd28fc95ced901f2f6b35a9ca27b615a (diff) |
Fix font options leak in cairo script surface
I added options->variations = strdup("slnt=0,wght=400,wdth=100"); to the
end of _cairo_font_options_init_default(). This makes all font option
objects own some memory that needs to be freed. Then I ran some random
test under valgrind and found memory leaks.
This commit makes the script surface finish the font options that it
contains. This fixes the following valgrind report:
25 bytes in 1 blocks are definitely lost in loss record 8 of 21
at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4ECBC99: strdup (strdup.c:42)
by 0x4886B7F: _cairo_font_options_init_default (cairo-font-options.c:86)
by 0x49768F4: _cairo_script_implicit_context_init (cairo-script-surface.c:3676)
by 0x4976B22: _cairo_script_surface_create_internal (cairo-script-surface.c:3733)
by 0x4976EA1: cairo_script_surface_create (cairo-script-surface.c:3962)
by 0x1B0A97: _cairo_boilerplate_script_create_surface (cairo-boilerplate-script.c:63)
by 0x129B7F: cairo_test_for_target (cairo-test.c:824)
by 0x12B37F: _cairo_test_context_run_for_target (cairo-test.c:1545)
by 0x12C385: _cairo_test_runner_draw (cairo-test-runner.c:258)
by 0x12DEB5: main (cairo-test-runner.c:962)
Signed-off-by: Uli Schlachter <psychon@znc.in>
-rw-r--r-- | src/cairo-script-surface.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c index 1175bd8f3..ca4db5a69 100644 --- a/src/cairo-script-surface.c +++ b/src/cairo-script-surface.c @@ -2204,6 +2204,7 @@ _cairo_script_surface_finish (void *abstract_surface) _cairo_pattern_fini (&surface->cr.current_source.base); _cairo_path_fixed_fini (&surface->cr.current_path); + _cairo_font_options_fini (&surface->cr.current_font_options); _cairo_surface_clipper_reset (&surface->clipper); status = cairo_device_acquire (&ctx->base); |