Make ftcrfont_close idempotent
This prevents crashes when running code like: (let ((font (open-font (find-font (font-spec ...))))) (close-font font) (close-font font)) * src/ftcrfont.c (ftcrfont_close): Make sure the function can be run several times in a row without crashing.
This commit is contained in:
parent
6c68600351
commit
1a38936299
1 changed files with 13 additions and 5 deletions
|
@ -344,12 +344,20 @@ ftcrfont_close (struct font *font)
|
|||
ftcrfont_info->hb_font = NULL;
|
||||
}
|
||||
#endif
|
||||
for (int i = 0; i < ftcrfont_info->metrics_nrows; i++)
|
||||
if (ftcrfont_info->metrics[i])
|
||||
xfree (ftcrfont_info->metrics[i]);
|
||||
if (ftcrfont_info->metrics)
|
||||
xfree (ftcrfont_info->metrics);
|
||||
cairo_scaled_font_destroy (ftcrfont_info->cr_scaled_font);
|
||||
{
|
||||
for (int i = 0; i < ftcrfont_info->metrics_nrows; i++)
|
||||
if (ftcrfont_info->metrics[i])
|
||||
xfree (ftcrfont_info->metrics[i]);
|
||||
if (ftcrfont_info->metrics)
|
||||
xfree (ftcrfont_info->metrics);
|
||||
ftcrfont_info->metrics = NULL;
|
||||
}
|
||||
if (ftcrfont_info->cr_scaled_font)
|
||||
{
|
||||
cairo_scaled_font_destroy (ftcrfont_info->cr_scaled_font);
|
||||
ftcrfont_info->cr_scaled_font = NULL;
|
||||
}
|
||||
unblock_input ();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue