diff src/insdel.c @ 114:8619ce7e4c50 r20-1b9

Import from CVS: tag r20-1b9
author cvs
date Mon, 13 Aug 2007 09:21:54 +0200
parents 0d2f883870bc
children cca96a509cfe
line wrap: on
line diff
--- a/src/insdel.c	Mon Aug 13 09:20:50 2007 +0200
+++ b/src/insdel.c	Mon Aug 13 09:21:54 2007 +0200
@@ -2275,10 +2275,18 @@
 			  int lockit)
 {
   /* This function can GC */
+  /* dmoore - This function can also kill the buffer buf, the current
+     buffer, and do anything it pleases.  So if you call it, be
+     careful. */
+  Lisp_Object buffer;
+  struct gcpro gcpro1;
+
   barf_if_buffer_read_only (buf, start, end);
 
   /* if this is the first modification, see about locking the buffer's
      file */
+  XSETBUFFER (buffer, buf);
+  GCPRO1 (buffer);
   if (!NILP (buf->filename) && lockit &&
       BUF_SAVE_MODIFF (buf) >= BUF_MODIFF (buf))
     {
@@ -2287,8 +2295,6 @@
 	/* Make binding buffer-file-name to nil effective.  */
 	lock_file (buf->file_truename);
 #else
-      Lisp_Object buffer;
-      XSETBUFFER (buffer, buf);
       /* At least warn if this file has changed on disk since it was visited.*/
       if (NILP (Fverify_visited_file_modtime (buffer))
 	  && !NILP (Ffile_exists_p (buf->filename)))
@@ -2296,6 +2302,11 @@
 			 buf->filename);
 #endif /* not CLASH_DETECTION */
     }
+  UNGCPRO;
+
+  /* #### dmoore - is this reasonable in case of buf being killed above? */
+  if (!BUFFER_LIVE_P (buf))
+    return;
 
   signal_before_change (buf, start, end);