mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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:
parent
973ecd8e90
commit
da22be9f33
@ -4422,7 +4422,7 @@ static void update_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos,
|
|||||||
int save_ws = p_ws;
|
int save_ws = p_ws;
|
||||||
int wraparound = false;
|
int wraparound = false;
|
||||||
pos_T p = (*pos);
|
pos_T p = (*pos);
|
||||||
static pos_T lastpos = { 0, 0, 0 };
|
static pos_T lastpos = { 0, 0, 0 };
|
||||||
static int cur = 0;
|
static int cur = 0;
|
||||||
static int cnt = 0;
|
static int cnt = 0;
|
||||||
static int exact_match = false;
|
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) {
|
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);
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user