vim-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 vim/vim#6211)
9b7cce28d5

Make code match latest Vim instead.
This commit is contained in:
zeertzjq
2022-08-25 19:35:17 +08:00
parent 99f8d34c8a
commit 4ecea0e001
4 changed files with 126 additions and 5 deletions

View File

@@ -4073,17 +4073,27 @@ static int open_cmdwin(void)
ga_clear(&winsizes);
return K_IGNORE;
}
// Don't let quitting the More prompt make this fail.
got_int = false;
// Set "cmdwin_type" before any autocommands may mess things up.
cmdwin_type = get_cmdline_type();
cmdwin_level = ccline.level;
// Create empty command-line buffer.
buf_open_scratch(0, _("[Command Line]"));
if (buf_open_scratch(0, _("[Command Line]")) == FAIL) {
// Some autocommand messed it up?
win_close(curwin, true, false);
ga_clear(&winsizes);
cmdwin_type = 0;
return Ctrl_C;
}
// Command-line buffer has bufhidden=wipe, unlike a true "scratch" buffer.
set_option_value_give_err("bh", 0L, "wipe", OPT_LOCAL);
curwin->w_p_rl = cmdmsg_rl;
cmdmsg_rl = false;
curbuf->b_p_ma = true;
curwin->w_p_fen = false;
curwin->w_p_rl = cmdmsg_rl;
cmdmsg_rl = false;
// Don't allow switching to another buffer.
curbuf->b_ro_locked++;