lkundrak / rpms / vim

Forked from rpms/vim 4 years ago
Clone
9e2bd49
To: vim_dev@googlegroups.com
9e2bd49
Subject: Patch 7.4.320
9e2bd49
Fcc: outbox
9e2bd49
From: Bram Moolenaar <Bram@moolenaar.net>
9e2bd49
Mime-Version: 1.0
9e2bd49
Content-Type: text/plain; charset=UTF-8
9e2bd49
Content-Transfer-Encoding: 8bit
9e2bd49
------------
9e2bd49
9e2bd49
Patch 7.4.320
9e2bd49
Problem:    Possible crash when an BufLeave autocommand deletes the buffer.
9e2bd49
Solution:   Check for the window pointer being valid.  Postpone freeing the
9e2bd49
	    window until autocommands are done. (Yasuhiro Matsumoto)
9e2bd49
Files:	    src/buffer.c, src/fileio.c, src/globals.h, src/window.c
9e2bd49
9e2bd49
9e2bd49
*** ../vim-7.4.319/src/buffer.c	2014-05-07 16:35:05.029152844 +0200
9e2bd49
--- src/buffer.c	2014-06-12 13:47:17.799737639 +0200
9e2bd49
***************
9e2bd49
*** 371,377 ****
9e2bd49
  	unload_buf = TRUE;
9e2bd49
  #endif
9e2bd49
  
9e2bd49
!     if (win != NULL)
9e2bd49
      {
9e2bd49
  	/* Set b_last_cursor when closing the last window for the buffer.
9e2bd49
  	 * Remember the last cursor position and window options of the buffer.
9e2bd49
--- 371,381 ----
9e2bd49
  	unload_buf = TRUE;
9e2bd49
  #endif
9e2bd49
  
9e2bd49
!     if (win != NULL
9e2bd49
! #ifdef FEAT_WINDOWS
9e2bd49
! 	&& win_valid(win)	/* in case autocommands closed the window */
9e2bd49
! #endif
9e2bd49
! 	    )
9e2bd49
      {
9e2bd49
  	/* Set b_last_cursor when closing the last window for the buffer.
9e2bd49
  	 * Remember the last cursor position and window options of the buffer.
9e2bd49
*** ../vim-7.4.319/src/fileio.c	2014-05-02 15:46:10.731268318 +0200
9e2bd49
--- src/fileio.c	2014-06-12 13:53:33.207751842 +0200
9e2bd49
***************
9e2bd49
*** 9549,9555 ****
9e2bd49
  
9e2bd49
      /*
9e2bd49
       * When stopping to execute autocommands, restore the search patterns and
9e2bd49
!      * the redo buffer.  Free buffers in the au_pending_free_buf list.
9e2bd49
       */
9e2bd49
      if (!autocmd_busy)
9e2bd49
      {
9e2bd49
--- 9549,9556 ----
9e2bd49
  
9e2bd49
      /*
9e2bd49
       * When stopping to execute autocommands, restore the search patterns and
9e2bd49
!      * the redo buffer.  Free any buffers in the au_pending_free_buf list and
9e2bd49
!      * free any windows in the au_pending_free_win list.
9e2bd49
       */
9e2bd49
      if (!autocmd_busy)
9e2bd49
      {
9e2bd49
***************
9e2bd49
*** 9562,9567 ****
9e2bd49
--- 9563,9574 ----
9e2bd49
  	    vim_free(au_pending_free_buf);
9e2bd49
  	    au_pending_free_buf = b;
9e2bd49
  	}
9e2bd49
+ 	while (au_pending_free_win != NULL)
9e2bd49
+ 	{
9e2bd49
+ 	    win_T *w = au_pending_free_win->w_next;
9e2bd49
+ 	    vim_free(au_pending_free_win);
9e2bd49
+ 	    au_pending_free_win = w;
9e2bd49
+ 	}
9e2bd49
      }
9e2bd49
  
9e2bd49
      /*
9e2bd49
*** ../vim-7.4.319/src/globals.h	2014-05-28 18:22:37.876225054 +0200
9e2bd49
--- src/globals.h	2014-06-12 13:54:29.163753959 +0200
9e2bd49
***************
9e2bd49
*** 387,396 ****
9e2bd49
   * which one is preferred, au_new_curbuf is set to it */
9e2bd49
  EXTERN buf_T	*au_new_curbuf INIT(= NULL);
9e2bd49
  
9e2bd49
! /* When deleting the buffer and autocmd_busy is TRUE, do not free the buffer
9e2bd49
!  * but link it in the list starting with au_pending_free_buf, using b_next.
9e2bd49
!  * Free the buffer when autocmd_busy is set to FALSE. */
9e2bd49
  EXTERN buf_T	*au_pending_free_buf INIT(= NULL);
9e2bd49
  #endif
9e2bd49
  
9e2bd49
  #ifdef FEAT_MOUSE
9e2bd49
--- 387,398 ----
9e2bd49
   * which one is preferred, au_new_curbuf is set to it */
9e2bd49
  EXTERN buf_T	*au_new_curbuf INIT(= NULL);
9e2bd49
  
9e2bd49
! /* When deleting a buffer/window and autocmd_busy is TRUE, do not free the
9e2bd49
!  * buffer/window. but link it in the list starting with
9e2bd49
!  * au_pending_free_buf/ap_pending_free_win, using b_next/w_next.
9e2bd49
!  * Free the buffer/window when autocmd_busy is being set to FALSE. */
9e2bd49
  EXTERN buf_T	*au_pending_free_buf INIT(= NULL);
9e2bd49
+ EXTERN win_T	*au_pending_free_win INIT(= NULL);
9e2bd49
  #endif
9e2bd49
  
9e2bd49
  #ifdef FEAT_MOUSE
9e2bd49
*** ../vim-7.4.319/src/window.c	2014-06-12 11:49:42.219470717 +0200
9e2bd49
--- src/window.c	2014-06-12 13:51:54.939748124 +0200
9e2bd49
***************
9e2bd49
*** 4597,4603 ****
9e2bd49
      if (wp != aucmd_win)
9e2bd49
  #endif
9e2bd49
  	win_remove(wp, tp);
9e2bd49
!     vim_free(wp);
9e2bd49
  
9e2bd49
  #ifdef FEAT_AUTOCMD
9e2bd49
      unblock_autocmds();
9e2bd49
--- 4597,4609 ----
9e2bd49
      if (wp != aucmd_win)
9e2bd49
  #endif
9e2bd49
  	win_remove(wp, tp);
9e2bd49
!     if (autocmd_busy)
9e2bd49
!     {
9e2bd49
! 	wp->w_next = au_pending_free_win;
9e2bd49
! 	au_pending_free_win = wp;
9e2bd49
!     }
9e2bd49
!     else
9e2bd49
! 	vim_free(wp);
9e2bd49
  
9e2bd49
  #ifdef FEAT_AUTOCMD
9e2bd49
      unblock_autocmds();
9e2bd49
*** ../vim-7.4.319/src/version.c	2014-06-12 13:28:26.771694851 +0200
9e2bd49
--- src/version.c	2014-06-12 13:40:23.507721966 +0200
9e2bd49
***************
9e2bd49
*** 736,737 ****
9e2bd49
--- 736,739 ----
9e2bd49
  {   /* Add new patch number below this line */
9e2bd49
+ /**/
9e2bd49
+     320,
9e2bd49
  /**/
9e2bd49
9e2bd49
-- 
9e2bd49
Life would be so much easier if we could just look at the source code.
9e2bd49
9e2bd49
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
9e2bd49
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
9e2bd49
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
9e2bd49
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///