mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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 #12231, closes #12227)
This commit is contained in:
@@ -4294,7 +4294,8 @@ f_setcmdline(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -3393,6 +3393,14 @@ endfunc
|
||||
|
||||
func Test_setcmdline()
|
||||
func SetText(text, pos)
|
||||
call assert_equal(0, setcmdline(test_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())
|
||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1444,
|
||||
/**/
|
||||
1443,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user