From: Dima Kogan Date: Mon, 9 Nov 2015 16:36:05 +0000 (+0200) Subject: Fix a memory leak in GC of font cache X-Git-Tag: emacs-25.0.90~865 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c6c16fb3f8fe5909baafd53c6b26153dec021064;p=emacs.git Fix a memory leak in GC of font cache * src/alloc.c (compact_font_cache_entry): Don't GC unmarked font entities if some of the fonts it references are marked. This plugs a memory leak. (Bug#21556) --- diff --git a/src/alloc.c b/src/alloc.c index 60751bcfe2b..81d644a16ad 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -5328,11 +5328,35 @@ compact_font_cache_entry (Lisp_Object entry) are not marked too. But we must be sure that nothing is marked within OBJ before we really drop it. */ for (i = 0; i < size; i++) - if (VECTOR_MARKED_P (XFONT_ENTITY (AREF (XCDR (obj), i)))) - break; + { + Lisp_Object objlist; + + if (VECTOR_MARKED_P (XFONT_ENTITY (AREF (XCDR (obj), i)))) + break; + + objlist = AREF (AREF (XCDR (obj), i), FONT_OBJLIST_INDEX); + for (; CONSP (objlist); objlist = XCDR (objlist)) + { + Lisp_Object val = XCAR (objlist); + struct font *font = XFONT_OBJECT (val); + + if (!NILP (AREF (val, FONT_TYPE_INDEX)) + && VECTOR_MARKED_P(font)) + break; + } + if (CONSP (objlist)) + { + /* Foiund a marked font, bail out. */ + break; + } + } if (i == size) - drop = 1; + { + /* No marked fonts were found, so this entire font + entity can be dropped. */ + drop = 1; + } } if (drop) *prev = XCDR (tail);