Patch 7.4.2006
Problem: Crash when using tabnext in BufUnload autocmd. (Norio Takagi)
Solution: First check that the current buffer is the right one. (Hirohito
Higashi)
Files: src/buffer.c, src/testdir/test_autocmd.vim
*** ../vim-7.4.2005/src/buffer.c 2016-07-03 17:47:21.854812653 +0200
--- src/buffer.c 2016-07-09 14:56:52.842034646 +0200
***************
*** 459,472 ****
#endif
buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0));
- if (
- #ifdef FEAT_WINDOWS
- win_valid(win) &&
- #else
- win != NULL &&
- #endif
- win->w_buffer == buf)
- win->w_buffer = NULL; /* make sure we don't use the buffer now */
#ifdef FEAT_AUTOCMD
/* Autocommands may have deleted the buffer. */
--- 459,464 ----
***************
*** 477,487 ****
return;
# endif
- /* Autocommands may have opened or closed windows for this buffer.
- * Decrement the count for the close we do here. */
- if (buf->b_nwindows > 0)
- --buf->b_nwindows;
-
/*
* It's possible that autocommands change curbuf to the one being deleted.
* This might cause the previous curbuf to be deleted unexpectedly. But
--- 469,474 ----
***************
*** 491,496 ****
--- 478,497 ----
*/
if (buf == curbuf && !is_curbuf)
return;
+
+ if (
+ #ifdef FEAT_WINDOWS
+ win_valid(win) &&
+ #else
+ win != NULL &&
+ #endif
+ win->w_buffer == buf)
+ win->w_buffer = NULL; /* make sure we don't use the buffer now */
+
+ /* Autocommands may have opened or closed windows for this buffer.
+ * Decrement the count for the close we do here. */
+ if (buf->b_nwindows > 0)
+ --buf->b_nwindows;
#endif
/* Change directories when the 'acd' option is set. */
*** ../vim-7.4.2005/src/testdir/test_autocmd.vim 2016-05-24
16:07:35.035276986 +0200
--- src/testdir/test_autocmd.vim 2016-07-09 14:57:03.857873028 +0200
***************
*** 60,62 ****
--- 60,80 ----
augroup! test_bufunload_group
endfunc
+
+ " SEGV occurs in older versions. (At least 7.4.2005 or older)
+ function Test_autocmd_bufunload_with_tabnext()
+ tabedit
+ tabfirst
+
+ augroup test_autocmd_bufunload_with_tabnext_group
+ autocmd!
+ autocmd BufUnload <buffer> tabnext
+ augroup END
+
+ quit
+ call assert_equal(2, tabpagenr('$'))
+
+ augroup! test_autocmd_bufunload_with_tabnext_group
+ tablast
+ quit
+ endfunc
*** ../vim-7.4.2005/src/version.c 2016-07-08 23:06:17.183567923 +0200
--- src/version.c 2016-07-09 14:51:00.615171129 +0200
***************
*** 760,761 ****
--- 760,763 ----
{ /* Add new patch number below this line */
+ /**/
+ 2006,
/**/
--
Marriage isn't a word. It's a sentence.
/// 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.