From: Po Lu Date: Sun, 18 May 2025 00:46:27 +0000 (+0800) Subject: Prevent double frees in closing fonts provided by the Haiku font driver X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6a4032ff80707f6ba3a64f041736fddb0b3fd458;p=emacs.git Prevent double frees in closing fonts provided by the Haiku font driver * src/haikufont.c (haikufont_close): Clear INFO->metrics, glyphs, be_font after they are released and do not attempt to access them if NULL. (bug#77478) (cherry picked from commit b9b52f009289ede7967a176bc6ed069c87514794) --- diff --git a/src/haikufont.c b/src/haikufont.c index 7522b92207f..29a76e674a5 100644 --- a/src/haikufont.c +++ b/src/haikufont.c @@ -890,25 +890,32 @@ haikufont_close (struct font *font) return; block_input (); - if (info && info->be_font) + if (info->be_font) BFont_close (info->be_font); - for (i = 0; i < info->metrics_nrows; i++) + if (info->metrics) { - if (info->metrics[i]) - xfree (info->metrics[i]); + for (i = 0; i < info->metrics_nrows; i++) + { + if (info->metrics[i]) + xfree (info->metrics[i]); + } + xfree (info->metrics); } - if (info->metrics) - xfree (info->metrics); - - for (i = 0; i < 0x100; ++i) + if (info->glyphs) { - if (info->glyphs[i]) - xfree (info->glyphs[i]); + for (i = 0; i < 0x100; ++i) + { + if (info->glyphs[i]) + xfree (info->glyphs[i]); + } + xfree (info->glyphs); } - xfree (info->glyphs); + info->metrics = NULL; + info->glyphs = NULL; + info->be_font = NULL; unblock_input (); }