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 <filipe.silva@gmail.com> in
http://lists.gnu.org/archive/html/emacs-devel/2017-03/msg00176.html.
This commit is contained in:
Eli Zaretskii 2017-03-11 10:25:05 +02:00
parent 996fcc74a4
commit 2b3065f0af

View file

@ -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));
}