aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_getln.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-25 19:35:17 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-08-25 21:38:11 +0800
commit4ecea0e001533d68f3032fe0512fc55360f295c0 (patch)
tree1c1fdd54a6a2bdd7240e22cc455ab45b7db1160a /src/nvim/ex_getln.c
parent99f8d34c8a7128a9adb43168ca5364ccbd568333 (diff)
downloadrneovim-4ecea0e001533d68f3032fe0512fc55360f295c0.tar.gz
rneovim-4ecea0e001533d68f3032fe0512fc55360f295c0.tar.bz2
rneovim-4ecea0e001533d68f3032fe0512fc55360f295c0.zip
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) https://github.com/vim/vim/commit/9b7cce28d568f0622d77c6c9878c2d4770c3b164 Make code match latest Vim instead.
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r--src/nvim/ex_getln.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index afec21a86f..ce4930d33e 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -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++;