From: Chong Yidong Date: Thu, 27 May 2010 15:49:01 +0000 (-0400) Subject: Fix redisplay crash (Bug#6177). X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~182^2~7 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f44a59e61a98543d4ce8b6952f1946dd955ce988;p=emacs.git Fix redisplay crash (Bug#6177). * xdisp.c (redisplay_window): After redisplay, check if point is still valid before setting it (Bug#6177). --- diff --git a/src/ChangeLog b/src/ChangeLog index d7128960af7..883d603bf35 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-05-27 Chong Yidong + + * xdisp.c (redisplay_window): After redisplay, check if point is + still valid before setting it (Bug#6177). + 2010-05-27 Glenn Morris * Makefile.in, autodeps.mk, deps.mk, ns.mk: diff --git a/src/xdisp.c b/src/xdisp.c index 699f375e2f4..31fa5f39d5f 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -14788,8 +14788,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*. */