diff options
author | Uli Schlachter <psychon@znc.in> | 2023-09-17 09:32:10 +0200 |
---|---|---|
committer | Uli Schlachter <psychon@znc.in> | 2023-09-17 09:32:10 +0200 |
commit | 7bf743a92fb10a18473accd5ae3c9005debed1c5 (patch) | |
tree | 411b6f6b2d83c4a8719e1c5771536e41e3ddbff1 /test | |
parent | 9529d02f6aecb234c1e4aaffd972eb439a74fb9a (diff) |
Fix font options leak in scaled font
A scaled font contains font options. Since commit 67eeed44, this can
contain an extra allocation for a custom palette. Since commit
edf9497c3a, this contains 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 the relevant code for creating and finishing scaled
fonts also clean up the font options.
The test added in the previous commit also hits this bug (I only found
these leaks accidentially!). Running "valgrind --leak-check=full
./cairo-test-suite -f leaks-set-scaled-font" no longer reports the following
after this change:
40 bytes in 1 blocks are definitely lost in loss record 1 of 11
at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4886C62: _cairo_font_options_init_copy (cairo-font-options.c:105)
by 0x48DAFFB: _cairo_scaled_font_init_key (cairo-scaled-font.c:675)
by 0x48DC077: cairo_scaled_font_create (cairo-scaled-font.c:1096)
by 0x15BF08: leaks_set_scaled_font (leaks.c:43)
by 0x129EF0: cairo_test_for_target (cairo-test.c:938)
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)
40 bytes in 1 blocks are definitely lost in loss record 2 of 11
at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4886C62: _cairo_font_options_init_copy (cairo-font-options.c:105)
by 0x49337BB: _cairo_ft_font_face_scaled_font_create (cairo-ft-font.c:2073)
by 0x48DC340: cairo_scaled_font_create (cairo-scaled-font.c:1176)
by 0x15BF08: leaks_set_scaled_font (leaks.c:43)
by 0x129EF0: cairo_test_for_target (cairo-test.c:938)
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)
40 bytes in 1 blocks are definitely lost in loss record 3 of 11
at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4886C62: _cairo_font_options_init_copy (cairo-font-options.c:105)
by 0x48DB280: _cairo_scaled_font_init (cairo-scaled-font.c:742)
by 0x4933804: _cairo_ft_font_face_scaled_font_create (cairo-ft-font.c:2076)
by 0x48DC340: cairo_scaled_font_create (cairo-scaled-font.c:1176)
by 0x15BF08: leaks_set_scaled_font (leaks.c:43)
by 0x129EF0: cairo_test_for_target (cairo-test.c:938)
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/leaks.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/test/leaks.c b/test/leaks.c index 612d4a1e6..ad7c85817 100644 --- a/test/leaks.c +++ b/test/leaks.c @@ -27,7 +27,8 @@ #include "cairo-test.h" -// Once upon a time, _cairo_gstate_fini leaked font options +// Once upon a time, _cairo_gstate_fini(), _cairo_scaled_font_fini_internal(), +// and _cairo_ft_scaled_font_fini() leaked font options. static cairo_test_status_t leaks_set_scaled_font (cairo_t *cr, int width, int height) { |