summaryrefslogtreecommitdiff
path: root/src/xdisp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xdisp.c')
-rw-r--r--src/xdisp.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 734b60bc1dd..7dcdf19431a 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13936,8 +13936,16 @@ redisplay_window (window, just_this_one_p)
(*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*. */