]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid aborts/assertion violations due to 'vim-empty-lines-mode'
authorEli Zaretskii <eliz@gnu.org>
Sat, 11 Mar 2017 08:25:05 +0000 (10:25 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 11 Mar 2017 08:25:05 +0000 (10:25 +0200)
* 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.

src/xdisp.c

index 1e7cb4ec6654f7c74762be40d75ff3773e32105d..7ff37a6fb488f506f745894f4075c686fb1d57b8 100644 (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));
        }