mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
term: free the data associated with the pixman image when destroying box-drawing glyphs
Closes #586
This commit is contained in:
parent
a3f6c8ac78
commit
cd37cdc940
2 changed files with 19 additions and 13 deletions
|
|
@ -172,6 +172,9 @@
|
|||
shifts (https://codeberg.org/dnkl/foot/issues/580).
|
||||
* `TEXT`+`STRING`+`UTF8_STRING` mime types not being recognized in
|
||||
clipboard offers (https://codeberg.org/dnkl/foot/issues/583).
|
||||
* Memory leak caused by custom box drawing glyphs not being completely
|
||||
freed when destroying a foot window instance
|
||||
(https://codeberg.org/dnkl/foot/issues/586).
|
||||
|
||||
|
||||
### Security
|
||||
|
|
|
|||
29
terminal.c
29
terminal.c
|
|
@ -609,6 +609,18 @@ term_pt_or_px_as_pixels(const struct terminal *term,
|
|||
: pt_or_px->px;
|
||||
}
|
||||
|
||||
static void
|
||||
free_box_drawing(struct fcft_glyph **box_drawing)
|
||||
{
|
||||
if (*box_drawing == NULL)
|
||||
return;
|
||||
|
||||
free(pixman_image_get_data((*box_drawing)->pix));
|
||||
pixman_image_unref((*box_drawing)->pix);
|
||||
free(*box_drawing);
|
||||
*box_drawing = NULL;
|
||||
}
|
||||
|
||||
static bool
|
||||
term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4])
|
||||
{
|
||||
|
|
@ -619,13 +631,8 @@ term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4])
|
|||
term->fonts[i] = fonts[i];
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < ALEN(term->box_drawing); i++) {
|
||||
if (term->box_drawing[i] != NULL) {
|
||||
pixman_image_unref(term->box_drawing[i]->pix);
|
||||
free(term->box_drawing[i]);
|
||||
term->box_drawing[i] = NULL;
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < ALEN(term->box_drawing); i++)
|
||||
free_box_drawing(&term->box_drawing[i]);
|
||||
|
||||
const int old_cell_width = term->cell_width;
|
||||
const int old_cell_height = term->cell_height;
|
||||
|
|
@ -1385,12 +1392,8 @@ term_destroy(struct terminal *term)
|
|||
for (size_t i = 0; i < 4; i++)
|
||||
free(term->font_sizes[i]);
|
||||
|
||||
for (size_t i = 0; i < ALEN(term->box_drawing); i++) {
|
||||
if (term->box_drawing[i] != NULL) {
|
||||
pixman_image_unref(term->box_drawing[i]->pix);
|
||||
free(term->box_drawing[i]);
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < ALEN(term->box_drawing); i++)
|
||||
free_box_drawing(&term->box_drawing[i]);
|
||||
|
||||
free(term->search.buf);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue