From 40a854a7d92da54b568745f8f6d5c2cebfa916bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Codru=C8=9B=20Constantin=20Gu=C8=99oi?= Date: Mon, 13 Mar 2017 19:17:07 +0200 Subject: [PATCH] Fixes segfaults caused by missing faces --- src/term.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/term.c b/src/term.c index 4397210965..fe3df9dac7 100644 --- a/src/term.c +++ b/src/term.c @@ -1892,6 +1892,12 @@ static void turn_on_face (struct frame *f, int face_id) { struct face *face = FACE_FROM_ID (f, face_id); + + /* The face might have been removed from the cache, using + the default face to prevent a segfault. */ + if (face == NULL) + face = FACE_FROM_ID (f, DEFAULT_FACE_ID); + unsigned long fg = face->foreground; unsigned long bg = face->background; struct tty_display_info *tty = FRAME_TTY (f); @@ -1952,6 +1958,12 @@ static void turn_off_face (struct frame *f, int face_id) { struct face *face = FACE_FROM_ID (f, face_id); + + /* The face might have been removed from the cache, using + the default face to prevent a segfault. */ + if (face == NULL) + face = FACE_FROM_ID (f, DEFAULT_FACE_ID); + struct tty_display_info *tty = FRAME_TTY (f); eassert (face != NULL); -- 2.12.0