mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.1402: crash with nasty autocommand
Problem: Crash with nasty autocommand. (gy741, Dominique Pelle)
Solution: Check that the new current buffer isn't wiped out. (closes vim/vim#2447)
9bca805ec4
This commit is contained in:
parent
e578d586f2
commit
5ae90c84ea
@ -1387,20 +1387,25 @@ void set_curbuf(buf_T *buf, int action)
|
|||||||
/* Don't restart Select mode after switching to another buffer. */
|
/* Don't restart Select mode after switching to another buffer. */
|
||||||
VIsual_reselect = FALSE;
|
VIsual_reselect = FALSE;
|
||||||
|
|
||||||
/* close_windows() or apply_autocmds() may change curbuf */
|
// close_windows() or apply_autocmds() may change curbuf and wipe out "buf"
|
||||||
prevbuf = curbuf;
|
prevbuf = curbuf;
|
||||||
bufref_T bufref;
|
bufref_T newbufref;
|
||||||
set_bufref(&bufref, prevbuf);
|
bufref_T prevbufref;
|
||||||
|
set_bufref(&prevbufref, prevbuf);
|
||||||
|
set_bufref(&newbufref, buf);
|
||||||
|
|
||||||
|
// 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)
|
if (!apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, false, curbuf)
|
||||||
|| (bufref_valid(&bufref) && !aborting())) {
|
|| (bufref_valid(&prevbufref) && bufref_valid(&newbufref)
|
||||||
|
&& !aborting())) {
|
||||||
if (prevbuf == curwin->w_buffer) {
|
if (prevbuf == curwin->w_buffer) {
|
||||||
reset_synblock(curwin);
|
reset_synblock(curwin);
|
||||||
}
|
}
|
||||||
if (unload) {
|
if (unload) {
|
||||||
close_windows(prevbuf, false);
|
close_windows(prevbuf, false);
|
||||||
}
|
}
|
||||||
if (bufref_valid(&bufref) && !aborting()) {
|
if (bufref_valid(&prevbufref) && !aborting()) {
|
||||||
win_T *previouswin = curwin;
|
win_T *previouswin = curwin;
|
||||||
if (prevbuf == curbuf)
|
if (prevbuf == curbuf)
|
||||||
u_sync(FALSE);
|
u_sync(FALSE);
|
||||||
|
@ -434,6 +434,7 @@ func s:AutoCommandOptionSet(match)
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_OptionSet()
|
func Test_OptionSet()
|
||||||
|
throw 'skipped: Nvim does not support test_override()'
|
||||||
if !has("eval") || !has("autocmd") || !exists("+autochdir")
|
if !has("eval") || !has("autocmd") || !exists("+autochdir")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -573,6 +574,7 @@ func Test_OptionSet()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_OptionSet_diffmode()
|
func Test_OptionSet_diffmode()
|
||||||
|
throw 'skipped: Nvim does not support test_override()'
|
||||||
call test_override('starting', 1)
|
call test_override('starting', 1)
|
||||||
" 18: Changing an option when enetering diff mode
|
" 18: Changing an option when enetering diff mode
|
||||||
new
|
new
|
||||||
@ -606,6 +608,7 @@ func Test_OptionSet_diffmode()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_OptionSet_diffmode_close()
|
func Test_OptionSet_diffmode_close()
|
||||||
|
throw 'skipped: Nvim does not support test_override()'
|
||||||
call test_override('starting', 1)
|
call test_override('starting', 1)
|
||||||
" 19: Try to close the current window when entering diff mode
|
" 19: Try to close the current window when entering diff mode
|
||||||
" should not segfault
|
" should not segfault
|
||||||
|
Loading…
Reference in New Issue
Block a user