changeset 108805:78199a49c4bf

Fix redisplay crash (Bug#6177). * xdisp.c (redisplay_window): After redisplay, check if point is still valid before setting it (Bug#6177).
author Chong Yidong <cyd@stupidchicken.com>
date Thu, 27 May 2010 11:49:01 -0400
parents 9b941507a02c
children 511da81b16c5 7cd8ffa6f7db
files src/ChangeLog src/xdisp.c
diffstat 2 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Thu May 27 11:28:58 2010 -0400
+++ b/src/ChangeLog	Thu May 27 11:49:01 2010 -0400
@@ -1,3 +1,8 @@
+2010-05-27  Chong Yidong  <cyd@stupidchicken.com>
+
+	* xdisp.c (redisplay_window): After redisplay, check if point is
+	still valid before setting it (Bug#6177).
+
 2010-05-27  Glenn Morris  <rgm@gnu.org>
 
 	* Makefile.in, autodeps.mk, deps.mk, ns.mk:
--- a/src/xdisp.c	Thu May 27 11:28:58 2010 -0400
+++ b/src/xdisp.c	Thu May 27 11:49:01 2010 -0400
@@ -14788,8 +14788,16 @@
         (*FRAME_TERMINAL (f)->redeem_scroll_bar_hook) (w);
     }
 
-  /* Restore current_buffer and value of point in it.  */
-  TEMP_SET_PT_BOTH (CHARPOS (opoint), BYTEPOS (opoint));
+  /* Restore current_buffer and value of point in it.  The window
+     update may have changed the buffer, so first make sure `opoint'
+     is still valid (Bug#6177).  */
+  if (CHARPOS (opoint) < BEGV)
+    TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
+  else if (CHARPOS (opoint) > ZV)
+    TEMP_SET_PT_BOTH (Z, Z_BYTE);
+  else
+    TEMP_SET_PT_BOTH (CHARPOS (opoint), BYTEPOS (opoint));
+
   set_buffer_internal_1 (old);
   /* Avoid an abort in TEMP_SET_PT_BOTH if the buffer has become
      shorter.  This can be caused by log truncation in *Messages*. */