From 4346235f61172f2c55dfbbd2b830233e005987e7 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 13 Jun 2014 16:53:24 +0300 Subject: [PATCH] Attempt to fix bug #17771 with segfault if "C-h h" is interrupted. src/alloc.c (cleanup_vector): Don't dereference a font driver pointer if it is NULL. --- src/ChangeLog | 5 +++++ src/alloc.c | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 3468cea6159..87b9b32510e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2014-06-13 Eli Zaretskii + + * alloc.c (cleanup_vector): Don't dereference a font driver + pointer if it is NULL. (Bug#17771) + 2014-06-11 Eli Zaretskii * xdisp.c (set_cursor_from_row): Fix an off-by-one error when diff --git a/src/alloc.c b/src/alloc.c index 12b3d4ba165..a3f3f5478cb 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2924,9 +2924,16 @@ cleanup_vector (struct Lisp_Vector *vector) && ((vector->header.size & PSEUDOVECTOR_SIZE_MASK) == FONT_OBJECT_MAX)) { - /* Attempt to catch subtle bugs like Bug#16140. */ - eassert (valid_font_driver (((struct font *) vector)->driver)); - ((struct font *) vector)->driver->close ((struct font *) vector); + struct font_driver *drv = ((struct font *) vector)->driver; + + /* The font driver might sometimes be NULL, e.g. if Emacs was + interrupted before it had time to set it up. */ + if (drv) + { + /* Attempt to catch subtle bugs like Bug#16140. */ + eassert (valid_font_driver (drv)); + drv->close ((struct font *) vector); + } } } -- 2.39.5