diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-01 15:42:01 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-08-01 21:54:18 +0800 |
commit | 7d45f1a5e8d05000a174dac149b56217c82e0214 (patch) | |
tree | f0bb7697ae8708e1ed735715c23d35b55ff72fed | |
parent | 6963c2bdcd3cc2a2f0466b23152e80fc0d037a2c (diff) | |
download | rneovim-7d45f1a5e8d05000a174dac149b56217c82e0214.tar.gz rneovim-7d45f1a5e8d05000a174dac149b56217c82e0214.tar.bz2 rneovim-7d45f1a5e8d05000a174dac149b56217c82e0214.zip |
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
-rw-r--r-- | src/nvim/mapping.c | 7 | ||||
-rw-r--r-- | src/nvim/testdir/test_maparg.vim | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index cbbe07635f..0bb397c748 100644 --- 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 index abbee7db95..6b69def374 100644 --- 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) |