summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChong Yidong <cyd@gnu.org>2011-11-23 14:47:09 +0800
committerChong Yidong <cyd@gnu.org>2011-11-23 14:47:09 +0800
commit6b21de180fba10432988d94d2b8f3e2521be5b17 (patch)
tree4951259a0078fbf1854d24fbf7ffa0f4f41e5ec6
parente37df6749a074832ee6f6e5241f912b9fa14f742 (diff)
downloademacs-6b21de180fba10432988d94d2b8f3e2521be5b17.tar.gz
* xdisp.c (compute_stop_pos): Check validity of end_charpos before using it.
Fixes: debbugs:5984
-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 51fa3b65be1..d26b893ced1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -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-
diff --git a/src/xdisp.c b/src/xdisp.c
index 8a8c1d08994..403272e7d0c 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