commit 7d45f1a5e8d05000a174dac149b56217c82e0214
parent 6963c2bdcd3cc2a2f0466b23152e80fc0d037a2c
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon, 1 Aug 2022 15:42:01 +0800
vim-patch:8.2.1773: crash when calling mapset() with a list as first argument
Problem: Crash when calling mapset() with a list as first argument.
Solution: Check for NULL. (closes vim/vim#7040)
https://github.com/vim/vim/commit/1b9129809d8269acb8e7c79d8fc99c7976b4f76e
Diffstat:
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
@@ -2132,8 +2132,11 @@ void f_mapset(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
char buf[NUMBUFLEN];
const char *which = tv_get_string_buf_chk(&argvars[0], buf);
- int mode = get_map_mode((char **)&which, 0);
- bool is_abbr = tv_get_number(&argvars[1]) != 0;
+ if (which == NULL) {
+ return;
+ }
+ const int mode = get_map_mode((char **)&which, 0);
+ const bool is_abbr = tv_get_number(&argvars[1]) != 0;
if (argvars[2].v_type != VAR_DICT) {
emsg(_(e_dictreq));
diff --git a/src/nvim/testdir/test_maparg.vim b/src/nvim/testdir/test_maparg.vim
@@ -239,6 +239,8 @@ func Test_mapset()
iunmap K
let &cpo = cpo_save
bwipe!
+
+ call assert_fails('call mapset([], v:false, {})', 'E730:')
endfunc
func Check_ctrlb_map(d, check_alt)