Patch 8.0.1402
Problem:    Crash with nasty autocommand. (gy741, Dominique Pelle)
Solution:   Check that the new current buffer isn't wiped out. (closes #2447)
Files:      src/buffer.c, src/testdir/test_autocmd.vim


*** ../vim-8.0.1401/src/buffer.c        2017-12-01 20:35:54.868077089 +0100
--- src/buffer.c        2017-12-18 12:26:12.155668966 +0100
***************
*** 1665,1671 ****
  #ifdef FEAT_SYN_HL
      long      old_tw = curbuf->b_p_tw;
  #endif
!     bufref_T  bufref;
  
      setpcmark();
      if (!cmdmod.keepalt)
--- 1665,1672 ----
  #ifdef FEAT_SYN_HL
      long      old_tw = curbuf->b_p_tw;
  #endif
!     bufref_T  newbufref;
!     bufref_T  prevbufref;
  
      setpcmark();
      if (!cmdmod.keepalt)
***************
*** 1675,1692 ****
      /* Don't restart Select mode after switching to another buffer. */
      VIsual_reselect = FALSE;
  
!     /* close_windows() or apply_autocmds() may change curbuf */
      prevbuf = curbuf;
!     set_bufref(&bufref, prevbuf);
  
  #ifdef FEAT_AUTOCMD
      if (!apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf)
  # ifdef FEAT_EVAL
!           || (bufref_valid(&bufref) && !aborting())
! # else
!           || bufref_valid(&bufref)
  # endif
!        )
  #endif
      {
  #ifdef FEAT_SYN_HL
--- 1676,1697 ----
      /* Don't restart Select mode after switching to another buffer. */
      VIsual_reselect = FALSE;
  
!     /* close_windows() or apply_autocmds() may change curbuf and wipe out 
"buf"
!      */
      prevbuf = curbuf;
!     set_bufref(&prevbufref, prevbuf);
!     set_bufref(&newbufref, buf);
  
  #ifdef FEAT_AUTOCMD
+     /* Autocommands may delete the curren buffer and/or the buffer we wan to 
go
+      * to.  In those cases don't close the buffer. */
      if (!apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf)
+           || (bufref_valid(&prevbufref)
+               && bufref_valid(&newbufref)
  # ifdef FEAT_EVAL
!               && !aborting()
  # endif
!              ))
  #endif
      {
  #ifdef FEAT_SYN_HL
***************
*** 1696,1704 ****
        if (unload)
            close_windows(prevbuf, FALSE);
  #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
!       if (bufref_valid(&bufref) && !aborting())
  #else
!       if (bufref_valid(&bufref))
  #endif
        {
            win_T  *previouswin = curwin;
--- 1701,1709 ----
        if (unload)
            close_windows(prevbuf, FALSE);
  #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
!       if (bufref_valid(&prevbufref) && !aborting())
  #else
!       if (bufref_valid(&prevbufref))
  #endif
        {
            win_T  *previouswin = curwin;
*** ../vim-8.0.1401/src/testdir/test_autocmd.vim        2017-12-16 
18:26:56.626992497 +0100
--- src/testdir/test_autocmd.vim        2017-12-18 12:26:40.799479202 +0100
***************
*** 1163,1165 ****
--- 1163,1173 ----
    unlet g:event
    bwipe!
  endfunc
+ 
+ func Test_nocatch_wipe_all_buffers()
+   " Real nasty autocommand: wipe all buffers on any event.
+   au * * bwipe *
+   call assert_fails('next x', 'E93')
+   bwipe
+   au!
+ endfunc
*** ../vim-8.0.1401/src/version.c       2017-12-17 21:54:51.240060608 +0100
--- src/version.c       2017-12-18 12:24:19.448416819 +0100
***************
*** 773,774 ****
--- 773,776 ----
  {   /* Add new patch number below this line */
+ /**/
+     1402,
  /**/

-- 
Support your right to bare arms!  Wear short sleeves!

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui