From: Eli Zaretskii Date: Sat, 12 Aug 2023 06:38:28 +0000 (+0300) Subject: Fix rare crashes in redisplay due to problems with fontsets X-Git-Tag: emacs-29.1.90~219 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=03e897c08facf8e920ee04cd505b72f5aa5a30cf;p=emacs.git Fix rare crashes in redisplay due to problems with fontsets * src/xdisp.c (get_next_display_element): If we have no usable face to display a character/composition, treat that as glyphless. (produce_glyphless_glyph): If neither it->face nor its ASCII face are usable, fall back to the frame's default font. (Bug#65198) --- diff --git a/src/xdisp.c b/src/xdisp.c index 9cddcfeda27..22508978298 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -8312,9 +8312,17 @@ get_next_display_element (struct it *it) && success_p && FRAME_WINDOW_P (it->f)) { - struct face *face = FACE_FROM_ID (it->f, it->face_id); + struct face *face = FACE_FROM_ID_OR_NULL (it->f, it->face_id); - if (it->what == IT_COMPOSITION && it->cmp_it.ch >= 0) + /* It shouldn't happen, ever, that FACE is NULL here, but + evidently some faulty fonts/fontsets can sometimes cause it. + In that case, we punt and consider the stuff undisplayable. */ + if (!face) + { + it->what = IT_GLYPHLESS; + it->glyphless_method = GLYPHLESS_DISPLAY_EMPTY_BOX; + } + else if (it->what == IT_COMPOSITION && it->cmp_it.ch >= 0) { /* Automatic composition with glyph-string. */ Lisp_Object gstring = composition_gstring_from_id (it->cmp_it.id); @@ -31781,9 +31789,12 @@ produce_glyphless_glyph (struct it *it, bool for_no_font, Lisp_Object acronym) int len; /* Get the metrics of the base font. We always refer to the current - ASCII face. */ - face = FACE_FROM_ID (it->f, it->face_id)->ascii_face; - font = face->font ? face->font : FRAME_FONT (it->f); + ASCII face, but if some faulty setup of fontsets causes that to + be NULL, we fall back to the frame's default font. */ + face = FACE_FROM_ID_OR_NULL (it->f, it->face_id); + if (face) + face = face->ascii_face; + font = (face && face->font) ? face->font : FRAME_FONT (it->f); normal_char_ascent_descent (font, -1, &it->ascent, &it->descent); it->ascent += font->baseline_offset; it->descent -= font->baseline_offset;