diff options
| author | Eli Zaretskii | 2018-05-05 11:52:29 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2018-06-02 12:30:30 +0300 |
| commit | e96245a5497ecbc6c58740a6b6bd1f848a44b26c (patch) | |
| tree | 8f132637a478bf3c50402d92355d1eb6089307c7 /src | |
| parent | 3a06e7245703f58aaee5c50cfaa410458614efa0 (diff) | |
| download | emacs-e96245a5497ecbc6c58740a6b6bd1f848a44b26c.tar.gz 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)
Diffstat (limited to 'src')
| -rw-r--r-- | src/font.c | 3 |
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) | |||
| 2906 | font = XFONT_OBJECT (font_object); | 2906 | font = XFONT_OBJECT (font_object); |
| 2907 | if (font->average_width > 0 && font->height > 0) | 2907 | if (font->average_width > 0 && font->height > 0) |
| 2908 | break; | 2908 | break; |
| 2909 | /* Avoid an infinite loop. */ | ||
| 2910 | if (psize > pixel_size + 15) | ||
| 2911 | return Qnil; | ||
| 2909 | } | 2912 | } |
| 2910 | ASET (font_object, FONT_SIZE_INDEX, make_number (pixel_size)); | 2913 | ASET (font_object, FONT_SIZE_INDEX, make_number (pixel_size)); |
| 2911 | FONT_ADD_LOG ("open", entity, font_object); | 2914 | FONT_ADD_LOG ("open", entity, font_object); |