aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog5
-rw-r--r--src/xdisp.c10
2 files changed, 12 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 51fa3b65be..d26b893ced 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-23 Chong Yidong <[email protected]>
+
+ * xdisp.c (compute_stop_pos): Check validity of end_charpos before
+ using it (Bug#5984).
+
2011-11-22 Eli Zaretskii <[email protected]>
* dispnew.c (adjust_glyph_matrix): Don't verify hash code of mode-
diff --git a/src/xdisp.c b/src/xdisp.c
index 8a8c1d0899..403272e7d0 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -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