From 48f9557c9e5e709e02f9ec538401bddb69dc2b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Codru=C8=9B=20Constantin=20Gu=C8=99oi?= Date: Mon, 13 Mar 2017 19:24:48 +0200 Subject: [PATCH] Fixes segfaults caused by missing faces --- src/dispextern.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dispextern.h b/src/dispextern.h index 679820d506..cbf2e857d8 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -1812,11 +1812,14 @@ struct face_cache bool_bf menu_face_changed_p : 1; }; -/* Return a non-null pointer to the cached face with ID on frame F. */ - -#define FACE_FROM_ID(F, ID) \ - (eassert (UNSIGNED_CMP (ID, <, FRAME_FACE_CACHE (F)->used)), \ - FRAME_FACE_CACHE (F)->faces_by_id[ID]) +/* Return a non-null pointer to the cached 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]) /* Return a pointer to the face with ID on frame F, or null if such a face doesn't exist. */ -- 2.12.0