From: Eli Zaretskii Date: Sat, 11 Mar 2017 08:25:05 +0000 (+0200) Subject: Avoid aborts/assertion violations due to 'vim-empty-lines-mode' X-Git-Tag: emacs-26.0.90~596 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2b3065f0afa0ef7019735845083395221fe26add;p=emacs.git 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. --- 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)); }