From c452fd02995d22899b2fd1717fab2b6ae4f69cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Codru=C8=9B=20Constantin=20Gu=C8=99oi?= Date: Mon, 13 Mar 2017 19:04:18 +0200 Subject: [PATCH] Fixes segfaults caused by missing faces --- src/dispextern.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/dispextern.h b/src/dispextern.h index 7b9ae78dcd..0df778db2f 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -1812,13 +1812,14 @@ struct face_cache bool_bf menu_face_changed_p : 1; }; -/* Return a pointer to the face with ID on frame F, or null if such a - face doesn't exist. */ - -#define FACE_FROM_ID(F, ID) \ - (UNSIGNED_CMP (ID, <, FRAME_FACE_CACHE (F)->used) \ - ? FRAME_FACE_CACHE (F)->faces_by_id[ID] \ - : NULL) +/* Return a pointer to the face with ID on frame F. In case the face + ID is greater that the number of elements in the face cache, it + uses a default face ID. */ + +#define FACE_FROM_ID(F, ID) \ + (UNSIGNED_CMP (ID, <, FRAME_FACE_CACHE (F)->used) \ + ? FRAME_FACE_CACHE (F)->faces_by_id[ID] \ + : FRAME_FACE_CACHE (F)->faces_by_id[DEFAULT_FACE_ID]) #ifdef HAVE_WINDOW_SYSTEM -- 2.12.0