]> git.eshelyaron.com Git - emacs.git/commitdiff
Adjust buffer text indirection counters at the end of Fkill_buffer.
authorDmitry Antipov <dmantipov@yandex.ru>
Wed, 25 Jul 2012 05:09:02 +0000 (09:09 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Wed, 25 Jul 2012 05:09:02 +0000 (09:09 +0400)
* buffer.c (Fkill_buffer): Adjust indirection counters when the
buffer is definitely dead.  This should really fix an issue reported
by Christoph Scholtes again.  (Bug#12007).
(init_buffer_once): Initialize indirection counters of
buffer_defaults and buffer_local_symbols (for sanity and safety).

src/ChangeLog
src/buffer.c

index a7ed81da2d237eb327c8a27c896e2a647be8f890..2c82af88f93f657b2081a6a717271426d730b838 100644 (file)
@@ -1,3 +1,12 @@
+2012-07-25  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       Adjust buffer text indirection counters at the end of Fkill_buffer.
+       * buffer.c (Fkill_buffer): Adjust indirection counters when the
+       buffer is definitely dead.  This should really fix an issue reported
+       by Christoph Scholtes again.  (Bug#12007).
+       (init_buffer_once): Initialize indirection counters of
+       buffer_defaults and buffer_local_symbols (for sanity and safety).
+
 2012-07-24  Eli Zaretskii  <eliz@gnu.org>
 
        * xdisp.c (init_iterator): Don't compute dimensions of truncation
@@ -7,7 +16,7 @@
 2012-07-24  Dmitry Antipov  <dmantipov@yandex.ru>
 
        Simplify copy_overlay.
-       * buffer.c (copy_overlay): Simplify, use build_marker.
+       * buffer.c (copy_overlay): Simplify.  Use build_marker.
        * lisp.h (struct Lisp_Overlay): Restore comment with minor tweaks.
 
 2012-07-23  Eli Zaretskii  <eliz@gnu.org>
index c017db7b0349dca5c490d84bbfd30ac5fa3d3ad5..06d385110c6c705b165ada783afbe057ecd506f8 100644 (file)
@@ -1560,14 +1560,6 @@ cleaning up all windows currently displaying the buffer to be killed. */)
   if (EQ (buffer, XWINDOW (minibuf_window)->buffer))
     return Qnil;
 
-  /* Notify our base buffer that we don't share the text anymore.  */
-  if (b->base_buffer)
-    {
-      eassert (b->indirections == -1);
-      b->base_buffer->indirections--;
-      eassert (b->base_buffer->indirections >= 0);
-    }
-
   /* When we kill an ordinary buffer which shares it's buffer text
      with indirect buffer(s), we must kill indirect buffer(s) too.
      We do it at this stage so nothing terrible happens if they
@@ -1708,7 +1700,15 @@ cleaning up all windows currently displaying the buffer to be killed. */)
   BVAR (b, name) = Qnil;
 
   BLOCK_INPUT;
-  if (! b->base_buffer)
+  if (b->base_buffer)
+    {
+      /* Notify our base buffer that we don't share the text anymore.  */
+      eassert (b->indirections == -1);
+      b->base_buffer->indirections--;
+      eassert (b->base_buffer->indirections >= 0);
+    }
+  else
+    /* No one shares our buffer text, can free it.  */
     free_buffer_text (b);
 
   if (b->newline_cache)
@@ -4897,6 +4897,9 @@ init_buffer_once (void)
   /* Prevent GC from getting confused.  */
   buffer_defaults.text = &buffer_defaults.own_text;
   buffer_local_symbols.text = &buffer_local_symbols.own_text;
+  /* No one will share the text with these buffers, but let's play it safe.  */
+  buffer_defaults.indirections = 0;
+  buffer_local_symbols.indirections = 0;
   BUF_INTERVALS (&buffer_defaults) = 0;
   BUF_INTERVALS (&buffer_local_symbols) = 0;
   XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize);