diff src/insdel.c @ 40:7e54bd776075 r19-15b103

Import from CVS: tag r19-15b103
author cvs
date Mon, 13 Aug 2007 08:54:25 +0200
parents 9ee227acff29
children 56c54cf7c5b6
line wrap: on
line diff
--- a/src/insdel.c	Mon Aug 13 08:54:02 2007 +0200
+++ b/src/insdel.c	Mon Aug 13 08:54:25 2007 +0200
@@ -1374,10 +1374,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))
     {
@@ -1386,8 +1394,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)))
@@ -1395,6 +1401,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);