]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid infloops in font_open_entity
authorEli Zaretskii <eliz@gnu.org>
Sat, 5 May 2018 08:52:29 +0000 (11:52 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 5 May 2018 08:52:29 +0000 (11:52 +0300)
* 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)

src/font.c

index ef3f92b59499f84ff713a7bded8db7f3ade35a0a..305bb14576affc1544671ac42f4b93ce1700d133 100644 (file)
@@ -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);