changeset 46921:40c8bb63c063

(save_restriction_restore): Defend from unchained marker.
author Richard M. Stallman <rms@gnu.org>
date Sat, 17 Aug 2002 04:55:17 +0000
parents a92cb918558c
children ee04d07683ab
files src/editfns.c
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/editfns.c	Sat Aug 17 04:53:57 2002 +0000
+++ b/src/editfns.c	Sat Aug 17 04:55:17 2002 +0000
@@ -2834,7 +2834,8 @@
       struct Lisp_Marker *end = XMARKER (XCDR (data));
       struct buffer *buf = beg->buffer; /* END should have the same buffer. */
 
-      if (beg->charpos != BUF_BEGV(buf) || end->charpos != BUF_ZV(buf))
+      if (buf /* Verify marker still points to a buffer.  */
+	  && (beg->charpos != BUF_BEGV (buf) || end->charpos != BUF_ZV (buf)))
 	/* The restriction has changed from the saved one, so restore
 	   the saved restriction.  */
 	{
@@ -2847,7 +2848,7 @@
 	    /* The point is outside the new visible range, move it inside. */
 	    SET_BUF_PT_BOTH (buf,
 			     clip_to_bounds (beg->charpos, pt, end->charpos),
-			     clip_to_bounds (beg->bytepos, BUF_PT_BYTE(buf),
+			     clip_to_bounds (beg->bytepos, BUF_PT_BYTE (buf),
 					     end->bytepos));
 	  
 	  buf->clip_changed = 1; /* Remember that the narrowing changed. */
@@ -2858,11 +2859,12 @@
     {
       struct buffer *buf = XBUFFER (data);
 
-      if (BUF_BEGV(buf) != BUF_BEG(buf) || BUF_ZV(buf) != BUF_Z(buf))
+      if (buf /* Verify marker still points to a buffer.  */
+	  && (BUF_BEGV (buf) != BUF_BEG (buf) || BUF_ZV (buf) != BUF_Z (buf)))
 	/* The buffer has been narrowed, get rid of the narrowing.  */
 	{
-	  SET_BUF_BEGV_BOTH (buf, BUF_BEG(buf), BUF_BEG_BYTE(buf));
-	  SET_BUF_ZV_BOTH (buf, BUF_Z(buf), BUF_Z_BYTE(buf));
+	  SET_BUF_BEGV_BOTH (buf, BUF_BEG (buf), BUF_BEG_BYTE (buf));
+	  SET_BUF_ZV_BOTH (buf, BUF_Z (buf), BUF_Z_BYTE (buf));
 
 	  buf->clip_changed = 1; /* Remember that the narrowing changed. */
 	}