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

@@ -4535,11 +4535,16 @@ void f_searchcount(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} }
if (argvars[0].v_type != VAR_UNKNOWN) { if (argvars[0].v_type != VAR_UNKNOWN) {
dict_T *dict = argvars[0].vval.v_dict; dict_T *dict;
dictitem_T *di; dictitem_T *di;
listitem_T *li; listitem_T *li;
bool error = false; 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); di = tv_dict_find(dict, (const char *)"timeout", -1);
if (di != NULL) { if (di != NULL) {
timeout = (long)tv_get_number_chk(&di->di_tv, &error); timeout = (long)tv_get_number_chk(&di->di_tv, &error);

View File

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