Patch 7.4.2309
Problem:    Crash when doing tabnext in a BufUnload autocmd. (Dominique Pelle)
Solution:   When detecting that the tab page changed, don't just abort but
            delete the window where w_buffer is NULL.
Files:      src/window.c, src/testdir/test_tabpage.vim


*** ../vim-7.4.2308/src/window.c        2016-08-29 22:48:12.177105943 +0200
--- src/window.c        2016-09-02 21:47:50.710142849 +0200
***************
*** 2379,2385 ****
  #endif
        close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, TRUE);
  #ifdef FEAT_AUTOCMD
!       if (win_valid(win))
            win->w_closing = FALSE;
  #endif
        /* Make sure curbuf is valid. It can become invalid if 'bufhidden' is
--- 2379,2385 ----
  #endif
        close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, TRUE);
  #ifdef FEAT_AUTOCMD
!       if (win_valid_any_tab(win))
            win->w_closing = FALSE;
  #endif
        /* Make sure curbuf is valid. It can become invalid if 'bufhidden' is
***************
*** 2399,2407 ****
        getout(0);
      }
  
!     /* Autocommands may have closed the window already, or closed the only
!      * other window or moved to another tab page. */
!     else if (!win_valid(win) || last_window() || curtab != prev_curtab
            || close_last_window_tabpage(win, free_buf, prev_curtab))
        return FAIL;
  
--- 2399,2416 ----
        getout(0);
      }
  
!     /* Autocommands may have moved to another tab page. */
!     if (curtab != prev_curtab && win_valid_any_tab(win)
!                                                     && win->w_buffer == NULL)
!     {
!       /* Need to close the window anyway, since the buffer is NULL. */
!       win_close_othertab(win, FALSE, prev_curtab);
!       return FAIL;
!     }
! 
!     /* Autocommands may have closed the window already or closed the only
!      * other window. */
!     if (!win_valid(win) || last_window()
            || close_last_window_tabpage(win, free_buf, prev_curtab))
        return FAIL;
  
***************
*** 2492,2503 ****
      int               free_tp = FALSE;
  
  #ifdef FEAT_AUTOCMD
!     if (win->w_closing || win->w_buffer->b_closing)
        return; /* window is already being closed */
  #endif
  
!     /* Close the link to the buffer. */
!     close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, FALSE);
  
      /* Careful: Autocommands may have closed the tab page or made it the
       * current tab page.  */
--- 2501,2515 ----
      int               free_tp = FALSE;
  
  #ifdef FEAT_AUTOCMD
!     /* Get here with win->w_buffer == NULL when win_close() detects the tab
!      * page changed. */
!     if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_closing))
        return; /* window is already being closed */
  #endif
  
!     if (win->w_buffer != NULL)
!       /* Close the link to the buffer. */
!       close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, FALSE);
  
      /* Careful: Autocommands may have closed the tab page or made it the
       * current tab page.  */
*** ../vim-7.4.2308/src/testdir/test_tabpage.vim        2016-08-21 
19:07:14.265008108 +0200
--- src/testdir/test_tabpage.vim        2016-09-02 21:42:10.277122715 +0200
***************
*** 218,221 ****
--- 218,235 ----
    bw!
  endfunction
  
+ func Test_tabnext_on_buf_unload()
+   " This once caused a crash
+   new
+   tabedit
+   tabfirst
+   au BufUnload <buffer> tabnext
+   q
+ 
+   while tabpagenr('$') > 1
+     quit
+   endwhile
+ endfunc
+ 
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-7.4.2308/src/version.c       2016-09-02 20:03:17.493151155 +0200
--- src/version.c       2016-09-02 21:46:19.298942732 +0200
***************
*** 765,766 ****
--- 765,768 ----
  {   /* Add new patch number below this line */
+ /**/
+     2309,
  /**/


-- 
hundred-and-one symptoms of being an internet addict:
137. You decide to stay in college for an additional year or two,
     just so you can have the free Internet access.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui