GNU bug report logs - #31316
Emacs hangs in `font_open_entity'

Previous Next

Package: emacs;

Reported by: Werner LEMBERG <wl <at> gnu.org>

Date: Mon, 30 Apr 2018 08:14:01 UTC

Severity: normal

Tags: moreinfo

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 31316 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Werner LEMBERG <wl <at> gnu.org>
Cc: 31316 <at> debbugs.gnu.org
Subject: Re: 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 <at> 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)




This bug report was last modified 5 years and 247 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.