From c0b8651477c1e47c198045d236b8e85d8a062b56 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 29 Aug 2024 12:56:27 +0300 Subject: [PATCH] Fix rare segfaults due to freed fontsets * src/xfaces.c (recompute_basic_faces): Force complete recalculation of non-ASCII faces and their fontsets if any non-ASCII faces are in the frame's face cache. (Bug#72692) (cherry picked from commit 13f69f254cfacfcc780b49c34e044b39dc333732) --- src/xfaces.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/xfaces.c b/src/xfaces.c index 684b6ccfac7..bbc3448e457 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -733,9 +733,18 @@ recompute_basic_faces (struct frame *f) { if (FRAME_FACE_CACHE (f)) { + bool non_basic_faces_cached = + FRAME_FACE_CACHE (f)->used > BASIC_FACE_ID_SENTINEL; clear_face_cache (false); if (!realize_basic_faces (f)) emacs_abort (); + /* The call to realize_basic_faces above recomputed the basic + faces and freed their fontsets, but if there are non-ASCII + faces in the cache, they might now be invalid, and they + reference fontsets that are no longer in Vfontset_table. We + therefore must force complete regeneration of all frame faces. */ + if (non_basic_faces_cached) + f->face_change = true; } } -- 2.39.5