[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#31316: Emacs hangs in `font_open_entity'
From: |
Eli Zaretskii |
Subject: |
bug#31316: Emacs hangs in `font_open_entity' |
Date: |
Mon, 30 Apr 2018 18:21:12 +0300 |
> Date: Mon, 30 Apr 2018 10:13:08 +0200 (CEST)
> From: Werner LEMBERG <wl@gnu.org>
>
> If I call `emacs -Q' and load the attached file `testchar' with
>
> C-x RET c gb18030 C-x C-f testchar
>
> Emacs hangs in `font_open_entity' on my GNU/Linux box:
>
> for (psize = pixel_size; ; psize++)
> {
> font_object = driver_list->driver->open (f, entity, psize);
> if (NILP (font_object))
> return Qnil;
> font = XFONT_OBJECT (font_object);
> if (font->average_width > 0 && font->height > 0)
> break;
> }
Does the patch below solve this without introducing any new problems?
> Both `average_width' and `height' are always zero for `font'
> regardless of `psize'; this effectively makes the above code an
> endless loop.
What kind of strange font has both of these always zero?
diff --git a/src/font.c b/src/font.c
index ef3f92b..daa6be0 100644
--- a/src/font.c
+++ b/src/font.c
@@ -2901,7 +2901,9 @@ font_open_entity (struct frame *f, Lisp_Object entity,
int pixel_size)
for (psize = pixel_size; ; psize++)
{
font_object = driver_list->driver->open (f, entity, psize);
- if (NILP (font_object))
+ if (NILP (font_object)
+ /* Avoid an infinite loop. */
+ || psize > pixel_size + 100)
return Qnil;
font = XFONT_OBJECT (font_object);
if (font->average_width > 0 && font->height > 0)