diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-01-05 22:11:28 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-01-05 22:11:28 +0800 |
commit | 6e1a59da6c37e6785e9535af18de8846e55fcd81 (patch) | |
tree | b1365c0e9d7196cd9190af2893d31d3e1a0e5daa | |
parent | f65b0d4236eef69b02390a51cf335b0836f35801 (diff) | |
download | rneovim-6e1a59da6c37e6785e9535af18de8846e55fcd81.tar.gz rneovim-6e1a59da6c37e6785e9535af18de8846e55fcd81.tar.bz2 rneovim-6e1a59da6c37e6785e9535af18de8846e55fcd81.zip |
vim-patch:8.2.2887: crash when passing null string to fullcommand()
Problem: Crash when passing null string to fullcommand().
Solution: Check for NULL pointer. (closes vim/vim#8256)
https://github.com/vim/vim/commit/4c8e8c6e19b75d632b042aa0ba0a2ab769b2162e
-rw-r--r-- | src/nvim/ex_docmd.c | 10 | ||||
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 1 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 71c34f98ff..fc7e3e0c96 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2891,13 +2891,17 @@ void f_fullcommand(typval_T *argvars, typval_T *rettv, FunPtr fptr) exarg_T ea; char_u *name = argvars[0].vval.v_string; - while (name[0] != NUL && name[0] == ':') { + rettv->v_type = VAR_STRING; + rettv->vval.v_string = NULL; + if (name == NULL) { + return; + } + + while (*name != NUL && *name == ':') { name++; } name = skip_range(name, NULL); - rettv->v_type = VAR_STRING; - ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; ea.cmdidx = (cmdidx_T)0; char_u *p = find_command(&ea, NULL); diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 1672b0e840..ef85c9e79a 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -500,6 +500,7 @@ func Test_fullcommand() for [in, want] in items(tests) call assert_equal(want, fullcommand(in)) endfor + call assert_equal('', fullcommand(v:_null_string)) call assert_equal('syntax', 'syn'->fullcommand()) endfunc |