]> code.delx.au - gnu-emacs/commitdiff
* xdisp.c (compute_stop_pos): Check validity of end_charpos before using it.
authorChong Yidong <cyd@gnu.org>
Wed, 23 Nov 2011 06:47:09 +0000 (14:47 +0800)
committerChong Yidong <cyd@gnu.org>
Wed, 23 Nov 2011 06:47:09 +0000 (14:47 +0800)
Fixes: debbugs:5984
src/ChangeLog
src/xdisp.c

index 51fa3b65be1b4ee86fa5b7ea481b4a6a94b69e37..d26b893ced129c21794495d8bf1f62ad6e5e388e 100644 (file)
@@ -1,3 +1,8 @@
+2011-11-23  Chong Yidong  <cyd@gnu.org>
+
+       * xdisp.c (compute_stop_pos): Check validity of end_charpos before
+       using it (Bug#5984).
+
 2011-11-22  Eli Zaretskii  <eliz@gnu.org>
 
        * dispnew.c (adjust_glyph_matrix): Don't verify hash code of mode-
index 8a8c1d089947e6cd780710cf0a39fe2c6cbcca59..403272e7d0cf41728d11c060ebbee06a1d0d2f06 100644 (file)
@@ -3166,13 +3166,11 @@ compute_stop_pos (struct it *it)
   Lisp_Object object, limit, position;
   EMACS_INT charpos, bytepos;
 
-  /* If nowhere else, stop at the end.  */
-  it->stop_charpos = it->end_charpos;
-
   if (STRINGP (it->string))
     {
       /* Strings are usually short, so don't limit the search for
         properties.  */
+      it->stop_charpos = it->end_charpos;
       object = it->string;
       limit = Qnil;
       charpos = IT_STRING_CHARPOS (*it);
@@ -3182,6 +3180,12 @@ compute_stop_pos (struct it *it)
     {
       EMACS_INT pos;
 
+      /* If end_charpos is out of range for some reason, such as a
+        misbehaving display function, rationalize it (Bug#5984).  */
+      if (it->end_charpos > ZV)
+       it->end_charpos = ZV;
+      it->stop_charpos = it->end_charpos;
+
       /* If next overlay change is in front of the current stop pos
         (which is IT->end_charpos), stop there.  Note: value of
         next_overlay_change is point-max if no overlay change