]> granicus.if.org Git - vim/commitdiff
updated for version 7.4a.042 v7.4a.042
authorBram Moolenaar <Bram@vim.org>
Wed, 24 Jul 2013 14:02:36 +0000 (16:02 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 24 Jul 2013 14:02:36 +0000 (16:02 +0200)
Problem:    Crash when BufUnload autocommands close all buffers. (Andrew
            Pimlott)
Solution:   Set curwin->w_buffer to curbuf to avoid NULL.

src/testdir/test8.in
src/testdir/test8.ok
src/version.c
src/window.c

index 6fe171546915cc410ba18dacb7f9fc6de1f04c60..d9d00d97ae9ce3157b9214e34263590b668f20ce 100644 (file)
@@ -1,4 +1,5 @@
 Test for BufWritePre autocommand that deletes or unloads the buffer.
+Test for BufUnload autocommand that unloads all other buffers.
 
 STARTTEST
 :so small.vim
@@ -16,6 +17,27 @@ $r2:.,/end of/w! Xxx2   " write test file Xxx2
 :bwipe test.out         " remove test.out from the buffer list
 :w                      " write it, will delete the buffer and give an error msg
 :w >>test.out           " Append contents of this file
+:au! BufWritePre
+:func CloseAll()
+  let i = 0
+  while i <= bufnr('$')
+    if i != bufnr('%') && bufloaded(i)
+      exe  i . "bunload"
+    endif
+    let i += 1
+  endwhile
+endfunc
+:func WriteToOut()
+  edit! test.out
+  $put ='VimLeave done'
+  write
+endfunc
+:set viminfo='100,nviminfo
+:au BufUnload * call CloseAll()
+:au VimLeave * call WriteToOut()
+:e small.vim
+:sp mbyte.vim
+:q
 :qa!
 ENDTEST
 
index 29b066a13fe6969850801e5c8a5abaf5ef7c9584..adecb2f4be7c87ac3fdee55549b32489ffdd7d09 100644 (file)
@@ -4,3 +4,4 @@ end of Xxx
 start of Xxx1
        test
 end of Xxx
+VimLeave done
index e435c1bdb4f99b9de313d905dc9919fb2f4f5848..652305e74dd3274232b737efb9a9018c68dc0601 100644 (file)
@@ -727,6 +727,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    42,
 /**/
     41,
 /**/
index 28bb12547c1396202bf9588deea3652898cff28e..d1c1e93d9b785f6e158821b9768fedaea8e76e11 100644 (file)
@@ -2291,8 +2291,13 @@ win_close(win, free_buf)
     if (only_one_window() && win_valid(win) && win->w_buffer == NULL
            && (last_window() || curtab != prev_curtab
                || close_last_window_tabpage(win, free_buf, prev_curtab)))
-       /* Autocommands have close all windows, quit now. */
+    {
+       /* Autocommands have close all windows, quit now.  Restore
+        * curwin->w_buffer, otherwise writing viminfo may fail. */
+       if (curwin->w_buffer == NULL)
+           curwin->w_buffer = curbuf;
        getout(0);
+    }
 
     /* Autocommands may have closed the window already, or closed the only
      * other window or moved to another tab page. */