summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2018-05-05 11:52:29 +0300
committerEli Zaretskii <eliz@gnu.org>2018-06-02 12:30:30 +0300
commite96245a5497ecbc6c58740a6b6bd1f848a44b26c (patch)
tree8f132637a478bf3c50402d92355d1eb6089307c7
parent3a06e7245703f58aaee5c50cfaa410458614efa0 (diff)
downloademacs-e96245a5497ecbc6c58740a6b6bd1f848a44b26c.tar.gz
emacs-e96245a5497ecbc6c58740a6b6bd1f848a44b26c.tar.bz2
emacs-e96245a5497ecbc6c58740a6b6bd1f848a44b26c.zip
Avoid infloops in font_open_entity
* src/font.c (font_open_entity): Fail after 15 iterations through the loop that looks for a font whose average_width and height are both positive. This avoids infinite loops for fonts that, e.g., report average_width of zero for any possible size we try. (Bug#31316) (cherry picked from commit e2879c1f837059335af89022b2a9ac9bc861e96d)
-rw-r--r--src/font.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/font.c b/src/font.c
index a6d3f5d4798..e53935a15cc 100644
--- a/src/font.c
+++ b/src/font.c
@@ -2906,6 +2906,9 @@ font_open_entity (struct frame *f, Lisp_Object entity, int pixel_size)
font = XFONT_OBJECT (font_object);
if (font->average_width > 0 && font->height > 0)
break;
+ /* Avoid an infinite loop. */
+ if (psize > pixel_size + 15)
+ return Qnil;
}
ASET (font_object, FONT_SIZE_INDEX, make_number (pixel_size));
FONT_ADD_LOG ("open", entity, font_object);