mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-26 21:20:29 +01:00
Fix font options leak in _cairo_surface_copy_similar_properties()
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.
_cairo_surface_copy_similar_properties() gets the font options of a
surface via cairo_surface_get_font_options(). This creates a copy of the
font variations that I added above. _cairo_surface_set_font_options()
then copies this again (it calls _cairo_font_options_init_copy). Thus,
the original copy is still owned by
_cairo_surface_copy_similar_properties() and needs to be freed.
This commit fixes four leaks in "valgrind --leak-check=full
./cairo-test-suite -f leaks-set-scaled-font". A random example is:
25 bytes in 1 blocks are definitely lost in loss record 4 of 25
at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4ECBC99: strdup (strdup.c:42)
by 0x4886C0C: _cairo_font_options_init_copy (cairo-font-options.c:99)
by 0x48F1DDE: cairo_surface_get_font_options (cairo-surface.c:1620)
by 0x48F0691: _cairo_surface_copy_similar_properties (cairo-surface.c:454)
by 0x48F087C: cairo_surface_create_similar (cairo-surface.c:528)
by 0x1B168A: _cairo_boilerplate_pdf_create_surface (cairo-boilerplate-pdf.c:92)
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>
This commit is contained in:
parent
4c1987b0f0
commit
29087868cd
1 changed files with 1 additions and 0 deletions
|
|
@ -453,6 +453,7 @@ _cairo_surface_copy_similar_properties (cairo_surface_t *surface,
|
|||
|
||||
cairo_surface_get_font_options (other, &options);
|
||||
_cairo_surface_set_font_options (surface, &options);
|
||||
_cairo_font_options_fini (&options);
|
||||
}
|
||||
|
||||
cairo_surface_set_fallback_resolution (surface,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue