mirror of
https://github.com/vim/vim.git
synced 2025-09-30 04:44:14 -04:00
patch 8.2.0911: crash when opening a buffer for the cmdline window fails
Problem: Crash when opening a buffer for the cmdline window fails. (Chris Barber) Solution: Check do_ecmd() succeeds. Reset got_int if "q" was used at the more prompt. (closes #6211)
This commit is contained in:
@@ -682,7 +682,8 @@ may_add_char_to_search(int firstc, int *c, incsearch_state_T *is_state)
|
|||||||
// NOTE: must call restore_last_search_pattern() before returning!
|
// NOTE: must call restore_last_search_pattern() before returning!
|
||||||
save_last_search_pattern();
|
save_last_search_pattern();
|
||||||
|
|
||||||
if (!do_incsearch_highlighting(firstc, &search_delim, is_state, &skiplen, &patlen))
|
if (!do_incsearch_highlighting(firstc, &search_delim, is_state,
|
||||||
|
&skiplen, &patlen))
|
||||||
{
|
{
|
||||||
restore_last_search_pattern();
|
restore_last_search_pattern();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -4205,10 +4206,19 @@ open_cmdwin(void)
|
|||||||
ga_clear(&winsizes);
|
ga_clear(&winsizes);
|
||||||
return K_IGNORE;
|
return K_IGNORE;
|
||||||
}
|
}
|
||||||
cmdwin_type = get_cmdline_type();
|
// Don't let quitting the More prompt make this fail.
|
||||||
|
got_int = FALSE;
|
||||||
|
|
||||||
// Create the command-line buffer empty.
|
// Create the command-line buffer empty.
|
||||||
(void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL);
|
if (do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL) == FAIL)
|
||||||
|
{
|
||||||
|
// Some autocommand messed it up?
|
||||||
|
win_close(curwin, TRUE);
|
||||||
|
ga_clear(&winsizes);
|
||||||
|
return Ctrl_C;
|
||||||
|
}
|
||||||
|
cmdwin_type = get_cmdline_type();
|
||||||
|
|
||||||
apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf);
|
apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf);
|
||||||
(void)setfname(curbuf, (char_u *)"[Command Line]", NULL, TRUE);
|
(void)setfname(curbuf, (char_u *)"[Command Line]", NULL, TRUE);
|
||||||
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);
|
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);
|
||||||
|
18
src/testdir/dumps/Test_cmdwin_interrupted.dump
Normal file
18
src/testdir/dumps/Test_cmdwin_interrupted.dump
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
> +0&#ffffff0@74
|
||||||
|
|~+0#4040ff13&| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|~| @73
|
||||||
|
|d+0#0000000&|o|n|e| @52|0|,|0|-|1| @8|A|l@1|
|
@@ -1183,6 +1183,33 @@ func Test_cmdwin_jump_to_win()
|
|||||||
call assert_equal(1, winnr('$'))
|
call assert_equal(1, winnr('$'))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_cmdwin_interrupted()
|
||||||
|
CheckScreendump
|
||||||
|
|
||||||
|
" aborting the :smile output caused the cmdline window to use the current
|
||||||
|
" buffer.
|
||||||
|
let lines =<< trim [SCRIPT]
|
||||||
|
au WinNew * smile
|
||||||
|
[SCRIPT]
|
||||||
|
call writefile(lines, 'XTest_cmdwin')
|
||||||
|
|
||||||
|
let buf = RunVimInTerminal('-S XTest_cmdwin', {'rows': 18})
|
||||||
|
call TermWait(buf, 1000)
|
||||||
|
" open cmdwin
|
||||||
|
call term_sendkeys(buf, "q:")
|
||||||
|
call TermWait(buf, 500)
|
||||||
|
" quit more prompt for :smile command
|
||||||
|
call term_sendkeys(buf, "q")
|
||||||
|
call TermWait(buf, 500)
|
||||||
|
" execute a simple command
|
||||||
|
call term_sendkeys(buf, "aecho 'done'\<CR>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_cmdwin_interrupted', {})
|
||||||
|
|
||||||
|
" clean up
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('XTest_cmdwin')
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for backtick expression in the command line
|
" Test for backtick expression in the command line
|
||||||
func Test_cmd_backtick()
|
func Test_cmd_backtick()
|
||||||
%argd
|
%argd
|
||||||
|
@@ -754,6 +754,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 */
|
||||||
|
/**/
|
||||||
|
911,
|
||||||
/**/
|
/**/
|
||||||
910,
|
910,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user