mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
vim-patch:9.0.1444: crash when passing NULL to setcmdline()
Problem: Crash when passing NULL to setcmdline(). (Andreas Louv) Solution: Use tv_get_string() instead of using v_string directly. (closes vim/vim#12231, closes vim/vim#12227)ac6cd31afc
(cherry picked from commit60549b1352
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
4b728cc3d7
commit
46e875a8a2
@@ -4209,7 +4209,8 @@ void f_setcmdline(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
}
|
||||
}
|
||||
|
||||
rettv->vval.v_number = set_cmdline_str(argvars[0].vval.v_string, pos);
|
||||
// Use tv_get_string() to handle a NULL string like an empty string.
|
||||
rettv->vval.v_number = set_cmdline_str(tv_get_string(&argvars[0]), pos);
|
||||
}
|
||||
|
||||
/// "setcmdpos()" function
|
||||
|
@@ -3532,6 +3532,14 @@ endfunc
|
||||
|
||||
func Test_setcmdline()
|
||||
func SetText(text, pos)
|
||||
call assert_equal(0, setcmdline(v:_null_string))
|
||||
call assert_equal('', getcmdline())
|
||||
call assert_equal(1, getcmdpos())
|
||||
|
||||
call assert_equal(0, setcmdline(''[: -1]))
|
||||
call assert_equal('', getcmdline())
|
||||
call assert_equal(1, getcmdpos())
|
||||
|
||||
autocmd CmdlineChanged * let g:cmdtype = expand('<afile>')
|
||||
call assert_equal(0, setcmdline(a:text))
|
||||
call assert_equal(a:text, getcmdline())
|
||||
|
Reference in New Issue
Block a user