diff src/window.c @ 5233:1899acc5aebd v7.4a.042

updated for version 7.4a.042 Problem: Crash when BufUnload autocommands close all buffers. (Andrew Pimlott) Solution: Set curwin->w_buffer to curbuf to avoid NULL.
author Bram Moolenaar <bram@vim.org>
date Wed, 24 Jul 2013 16:02:36 +0200
parents 8edba3805d78
children 647596ab1ae2
line wrap: on
line diff
--- a/src/window.c
+++ b/src/window.c
@@ -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. */