mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
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)
This commit is contained in:
parent
ee1deb4a00
commit
30445cb6e9
27
src/buffer.c
27
src/buffer.c
@ -459,14 +459,6 @@ aucmd_abort:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
buf_freeall(buf, (del_buf ? BFA_DEL : 0) + (wipe_buf ? BFA_WIPE : 0));
|
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
|
#ifdef FEAT_AUTOCMD
|
||||||
/* Autocommands may have deleted the buffer. */
|
/* Autocommands may have deleted the buffer. */
|
||||||
@ -477,11 +469,6 @@ aucmd_abort:
|
|||||||
return;
|
return;
|
||||||
# endif
|
# 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.
|
* It's possible that autocommands change curbuf to the one being deleted.
|
||||||
* This might cause the previous curbuf to be deleted unexpectedly. But
|
* This might cause the previous curbuf to be deleted unexpectedly. But
|
||||||
@ -491,6 +478,20 @@ aucmd_abort:
|
|||||||
*/
|
*/
|
||||||
if (buf == curbuf && !is_curbuf)
|
if (buf == curbuf && !is_curbuf)
|
||||||
return;
|
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
|
#endif
|
||||||
|
|
||||||
/* Change directories when the 'acd' option is set. */
|
/* Change directories when the 'acd' option is set. */
|
||||||
|
@ -60,3 +60,21 @@ function Test_bufunload()
|
|||||||
|
|
||||||
augroup! test_bufunload_group
|
augroup! test_bufunload_group
|
||||||
endfunc
|
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
|
||||||
|
@ -758,6 +758,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2006,
|
||||||
/**/
|
/**/
|
||||||
2005,
|
2005,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user