diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-07-04 13:27:11 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-07-04 13:27:11 +0200 |
commit | 1d97efce0ce31ddf0dd4c1ae2228ef4caee6880c (patch) | |
tree | 84282e48cccf1b5ff809d044f8a39e41adbd1fd9 /src | |
parent | 6c72fd51a899e6f0c272b08b9784d3c7a3cede20 (diff) |
patch 8.2.3097: crash when using "quit" at recovery promptv8.2.3097
Problem: Crash when using "quit" at recovery prompt and autocommands are
triggered.
Solution: Block autocommands when creating an empty buffer to use as the
current buffer. (closes #8506)
Diffstat (limited to 'src')
-rw-r--r-- | src/buffer.c | 5 | ||||
-rw-r--r-- | src/testdir/test_swap.vim | 12 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 19 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c index 59f51aaf7a..60aa32f0c9 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1130,7 +1130,12 @@ handle_swap_exists(bufref_T *old_curbuf) close_buffer(curwin, curbuf, DOBUF_UNLOAD, FALSE, FALSE); if (old_curbuf == NULL || !bufref_valid(old_curbuf) || old_curbuf->br_buf == curbuf) + { + // Block autocommands here because curwin->w_buffer is NULL. + block_autocmds(); buf = buflist_new(NULL, NULL, 1L, BLN_CURBUF | BLN_LISTED); + unblock_autocmds(); + } else buf = old_curbuf->br_buf; if (buf != NULL) diff --git a/src/testdir/test_swap.vim b/src/testdir/test_swap.vim index caacd7e175..4bc325d333 100644 --- a/src/testdir/test_swap.vim +++ b/src/testdir/test_swap.vim @@ -360,6 +360,7 @@ func Test_swap_prompt_splitwin() let buf = RunVimInTerminal('', {'rows': 20}) call term_sendkeys(buf, ":set nomore\n") call term_sendkeys(buf, ":set noruler\n") + call term_sendkeys(buf, ":split Xfile1\n") call TermWait(buf) call WaitForAssert({-> assert_match('^\[O\]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: $', term_getline(buf, 20))}) @@ -371,8 +372,19 @@ func Test_swap_prompt_splitwin() call TermWait(buf) call WaitForAssert({-> assert_match('^1$', term_getline(buf, 20))}) call StopVimInTerminal(buf) + + " This caused Vim to crash when typing "q". + " TODO: it does not actually reproduce the crash. + call writefile(['au BufAdd * set virtualedit=all'], 'Xvimrc') + + let buf = RunVimInTerminal('-u Xvimrc Xfile1', {'rows': 20, 'wait_for_ruler': 0}) + call TermWait(buf) + call WaitForAssert({-> assert_match('^\[O\]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:', term_getline(buf, 20))}) + call term_sendkeys(buf, "q") + %bwipe! call delete('Xfile1') + call delete('Xvimrc') endfunc func Test_swap_symlink() diff --git a/src/version.c b/src/version.c index fde11a75ec..f6d5758aca 100644 --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3097, +/**/ 3096, /**/ 3095, |