From: Dmitry Antipov Date: Mon, 22 Sep 2014 05:34:05 +0000 (+0400) Subject: On OSX, do not free font-specific data more than once (Bug#18501). X-Git-Tag: emacs-24.3.94~21 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fc5ebc3f497a152132407d57a14cce147d59d29c;p=emacs.git On OSX, do not free font-specific data more than once (Bug#18501). * macfont.m (macfont_close): Release and free font-specific data only if it wasn't previously freed. --- diff --git a/src/ChangeLog b/src/ChangeLog index 684de498522..4d969d73279 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2014-09-22 Dmitry Antipov + + On OSX, do not free font-specific data more than once (Bug#18501). + * macfont.m (macfont_close): Release and free font-specific data + only if it wasn't previously freed. + 2014-09-21 David Caldwell (tiny change) * unexmacosx.c (dump_it): Improve error message. diff --git a/src/macfont.m b/src/macfont.m index 1bb3fb14134..69bde9f66a7 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -2616,20 +2616,25 @@ static void macfont_close (struct font *font) { struct macfont_info *macfont_info = (struct macfont_info *) font; - int i; - block_input (); - CFRelease (macfont_info->macfont); - CGFontRelease (macfont_info->cgfont); - if (macfont_info->screen_font) - CFRelease (macfont_info->screen_font); - macfont_release_cache (macfont_info->cache); - for (i = 0; i < macfont_info->metrics_nrows; i++) - if (macfont_info->metrics[i]) - xfree (macfont_info->metrics[i]); - if (macfont_info->metrics) - xfree (macfont_info->metrics); - unblock_input (); + if (macfont_info->cache) + { + int i; + + block_input (); + CFRelease (macfont_info->macfont); + CGFontRelease (macfont_info->cgfont); + if (macfont_info->screen_font) + CFRelease (macfont_info->screen_font); + macfont_release_cache (macfont_info->cache); + for (i = 0; i < macfont_info->metrics_nrows; i++) + if (macfont_info->metrics[i]) + xfree (macfont_info->metrics[i]); + if (macfont_info->metrics) + xfree (macfont_info->metrics); + macfont_info->cache = NULL; + unblock_input (); + } } static int