Karsten Hopp ce80b8
To: vim_dev@googlegroups.com
Karsten Hopp ce80b8
Subject: Patch 7.3.390
Karsten Hopp ce80b8
Fcc: outbox
Karsten Hopp ce80b8
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp ce80b8
Mime-Version: 1.0
Karsten Hopp ce80b8
Content-Type: text/plain; charset=UTF-8
Karsten Hopp ce80b8
Content-Transfer-Encoding: 8bit
Karsten Hopp ce80b8
------------
Karsten Hopp ce80b8
Karsten Hopp ce80b8
Patch 7.3.390
Karsten Hopp ce80b8
Problem:    Using NULL buffer pointer in a window.
Karsten Hopp ce80b8
Solution:   Check for w_buffer being NULL in more places. (Bjorn Winckler)
Karsten Hopp ce80b8
Files:	    src/ex_cmds.c, src/quickfix.c, src/window.c
Karsten Hopp ce80b8
Karsten Hopp ce80b8
Karsten Hopp ce80b8
*** ../vim-7.3.389/src/ex_cmds.c	2011-11-30 17:01:55.000000000 +0100
Karsten Hopp ce80b8
--- src/ex_cmds.c	2011-12-30 14:59:57.000000000 +0100
Karsten Hopp ce80b8
***************
Karsten Hopp ce80b8
*** 3390,3395 ****
Karsten Hopp ce80b8
--- 3390,3402 ----
Karsten Hopp ce80b8
  				      (flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD);
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
  #ifdef FEAT_AUTOCMD
Karsten Hopp ce80b8
+ 		/* Autocommands may open a new window and leave oldwin open
Karsten Hopp ce80b8
+ 		 * which leads to crashes since the above call sets
Karsten Hopp ce80b8
+ 		 * oldwin->w_buffer to NULL. */
Karsten Hopp ce80b8
+ 		if (curwin != oldwin && oldwin != aucmd_win
Karsten Hopp ce80b8
+ 			     && win_valid(oldwin) && oldwin->w_buffer == NULL)
Karsten Hopp ce80b8
+ 		    win_close(oldwin, FALSE);
Karsten Hopp ce80b8
+ 
Karsten Hopp ce80b8
  # ifdef FEAT_EVAL
Karsten Hopp ce80b8
  		if (aborting())	    /* autocmds may abort script processing */
Karsten Hopp ce80b8
  		{
Karsten Hopp ce80b8
*** ../vim-7.3.389/src/quickfix.c	2011-08-10 18:36:49.000000000 +0200
Karsten Hopp ce80b8
--- src/quickfix.c	2011-12-30 14:45:19.000000000 +0100
Karsten Hopp ce80b8
***************
Karsten Hopp ce80b8
*** 2675,2681 ****
Karsten Hopp ce80b8
  bt_quickfix(buf)
Karsten Hopp ce80b8
      buf_T	*buf;
Karsten Hopp ce80b8
  {
Karsten Hopp ce80b8
!     return (buf->b_p_bt[0] == 'q');
Karsten Hopp ce80b8
  }
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
  /*
Karsten Hopp ce80b8
--- 2675,2681 ----
Karsten Hopp ce80b8
  bt_quickfix(buf)
Karsten Hopp ce80b8
      buf_T	*buf;
Karsten Hopp ce80b8
  {
Karsten Hopp ce80b8
!     return buf != NULL && buf->b_p_bt[0] == 'q';
Karsten Hopp ce80b8
  }
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
  /*
Karsten Hopp ce80b8
***************
Karsten Hopp ce80b8
*** 2686,2693 ****
Karsten Hopp ce80b8
  bt_nofile(buf)
Karsten Hopp ce80b8
      buf_T	*buf;
Karsten Hopp ce80b8
  {
Karsten Hopp ce80b8
!     return (buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
Karsten Hopp ce80b8
! 	    || buf->b_p_bt[0] == 'a';
Karsten Hopp ce80b8
  }
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
  /*
Karsten Hopp ce80b8
--- 2686,2693 ----
Karsten Hopp ce80b8
  bt_nofile(buf)
Karsten Hopp ce80b8
      buf_T	*buf;
Karsten Hopp ce80b8
  {
Karsten Hopp ce80b8
!     return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
Karsten Hopp ce80b8
! 	    || buf->b_p_bt[0] == 'a');
Karsten Hopp ce80b8
  }
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
  /*
Karsten Hopp ce80b8
***************
Karsten Hopp ce80b8
*** 2697,2703 ****
Karsten Hopp ce80b8
  bt_dontwrite(buf)
Karsten Hopp ce80b8
      buf_T	*buf;
Karsten Hopp ce80b8
  {
Karsten Hopp ce80b8
!     return (buf->b_p_bt[0] == 'n');
Karsten Hopp ce80b8
  }
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
      int
Karsten Hopp ce80b8
--- 2697,2703 ----
Karsten Hopp ce80b8
  bt_dontwrite(buf)
Karsten Hopp ce80b8
      buf_T	*buf;
Karsten Hopp ce80b8
  {
Karsten Hopp ce80b8
!     return buf != NULL && buf->b_p_bt[0] == 'n';
Karsten Hopp ce80b8
  }
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
      int
Karsten Hopp ce80b8
*** ../vim-7.3.389/src/window.c	2011-09-14 14:43:21.000000000 +0200
Karsten Hopp ce80b8
--- src/window.c	2011-12-30 14:44:18.000000000 +0100
Karsten Hopp ce80b8
***************
Karsten Hopp ce80b8
*** 2170,2176 ****
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
      /* When closing the help window, try restoring a snapshot after closing
Karsten Hopp ce80b8
       * the window.  Otherwise clear the snapshot, it's now invalid. */
Karsten Hopp ce80b8
!     if (win->w_buffer->b_help)
Karsten Hopp ce80b8
  	help_window = TRUE;
Karsten Hopp ce80b8
      else
Karsten Hopp ce80b8
  	clear_snapshot(curtab, SNAP_HELP_IDX);
Karsten Hopp ce80b8
--- 2170,2176 ----
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
      /* When closing the help window, try restoring a snapshot after closing
Karsten Hopp ce80b8
       * the window.  Otherwise clear the snapshot, it's now invalid. */
Karsten Hopp ce80b8
!     if (win->w_buffer != NULL && win->w_buffer->b_help)
Karsten Hopp ce80b8
  	help_window = TRUE;
Karsten Hopp ce80b8
      else
Karsten Hopp ce80b8
  	clear_snapshot(curtab, SNAP_HELP_IDX);
Karsten Hopp ce80b8
***************
Karsten Hopp ce80b8
*** 2214,2226 ****
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
  #ifdef FEAT_SYN_HL
Karsten Hopp ce80b8
      /* Free independent synblock before the buffer is freed. */
Karsten Hopp ce80b8
!     reset_synblock(win);
Karsten Hopp ce80b8
  #endif
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
      /*
Karsten Hopp ce80b8
       * Close the link to the buffer.
Karsten Hopp ce80b8
       */
Karsten Hopp ce80b8
!     close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0);
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
      /* Autocommands may have closed the window already, or closed the only
Karsten Hopp ce80b8
       * other window or moved to another tab page. */
Karsten Hopp ce80b8
--- 2214,2228 ----
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
  #ifdef FEAT_SYN_HL
Karsten Hopp ce80b8
      /* Free independent synblock before the buffer is freed. */
Karsten Hopp ce80b8
!     if (win->w_buffer != NULL)
Karsten Hopp ce80b8
! 	reset_synblock(win);
Karsten Hopp ce80b8
  #endif
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
      /*
Karsten Hopp ce80b8
       * Close the link to the buffer.
Karsten Hopp ce80b8
       */
Karsten Hopp ce80b8
!     if (win->w_buffer != NULL)
Karsten Hopp ce80b8
! 	close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0);
Karsten Hopp ce80b8
  
Karsten Hopp ce80b8
      /* Autocommands may have closed the window already, or closed the only
Karsten Hopp ce80b8
       * other window or moved to another tab page. */
Karsten Hopp ce80b8
*** ../vim-7.3.389/src/version.c	2011-12-30 14:14:16.000000000 +0100
Karsten Hopp ce80b8
--- src/version.c	2011-12-30 14:38:39.000000000 +0100
Karsten Hopp ce80b8
***************
Karsten Hopp ce80b8
*** 716,717 ****
Karsten Hopp ce80b8
--- 716,719 ----
Karsten Hopp ce80b8
  {   /* Add new patch number below this line */
Karsten Hopp ce80b8
+ /**/
Karsten Hopp ce80b8
+     390,
Karsten Hopp ce80b8
  /**/
Karsten Hopp ce80b8
Karsten Hopp ce80b8
-- 
Karsten Hopp ce80b8
There can't be a crisis today, my schedule is already full.
Karsten Hopp ce80b8
Karsten Hopp ce80b8
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp ce80b8
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp ce80b8
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp ce80b8
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///