From 2b3065f0afa0ef7019735845083395221fe26add Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 11 Mar 2017 10:25:05 +0200 Subject: [PATCH] Avoid aborts/assertion violations due to 'vim-empty-lines-mode' * src/xdisp.c (handle_single_display_spec): If position to be restored after processing the display property comes from an overlay, protect against that overlay's end point being outside of the narrowed region. Reported by Filipe Silva in http://lists.gnu.org/archive/html/emacs-devel/2017-03/msg00176.html. --- src/xdisp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/xdisp.c b/src/xdisp.c index 1e7cb4ec665..7ff37a6fb48 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -4999,6 +4999,14 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, { ptrdiff_t ovendpos = OVERLAY_POSITION (OVERLAY_END (overlay)); + /* Some borderly-sane Lisp might call us with the current + buffer narrowed so that overlay-end is outside the + POINT_MIN..POINT_MAX region, which will then cause + various assertion violations and crashes down the road, + starting with pop_it when it will attempt to use POSITION + set below. Prevent that. */ + ovendpos = clip_to_bounds (BEGV, ovendpos, ZV); + if (ovendpos > CHARPOS (*position)) SET_TEXT_POS (*position, ovendpos, CHAR_TO_BYTE (ovendpos)); } -- 2.39.5