From e96245a5497ecbc6c58740a6b6bd1f848a44b26c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 5 May 2018 11:52:29 +0300 Subject: [PATCH] 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) --- src/font.c | 3 +++ 1 file changed, 3 insertions(+) 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); -- 2.39.5