vim-patch:8.2.0896: crash when calling searchcount() with a string

Problem:    Crash when calling searchcount() with a string.
Solution:   Check the argument is a dict. (closes vim/vim#6192)
14681627f3
This commit is contained in:
shadmansaleh 2021-04-20 22:51:29 +06:00
parent 973ecd8e90
commit da22be9f33
2 changed files with 11 additions and 2 deletions

View File

@ -4422,7 +4422,7 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,
int save_ws = p_ws;
int wraparound = false;
pos_T p = (*pos);
static pos_T lastpos = { 0, 0, 0 };
static pos_T lastpos = { 0, 0, 0 };
static int cur = 0;
static int cnt = 0;
static int exact_match = false;
@ -4535,11 +4535,16 @@ void f_searchcount(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
if (argvars[0].v_type != VAR_UNKNOWN) {
dict_T *dict = argvars[0].vval.v_dict;
dict_T *dict;
dictitem_T *di;
listitem_T *li;
bool error = false;
if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL) {
EMSG(_(e_dictreq));
return;
}
dict = argvars[0].vval.v_dict;
di = tv_dict_find(dict, (const char *)"timeout", -1);
if (di != NULL) {
timeout = (long)tv_get_number_chk(&di->di_tv, &error);

View File

@ -259,6 +259,10 @@ func Test_search_stat()
bwipe!
endfunc
func Test_searchcount_fails()
call assert_fails('echo searchcount("boo!")', 'E715:')
endfunc
func Test_search_stat_foldopen()
CheckScreendump