comparison src/search.c @ 20685:4c66962d322b v8.2.0896

patch 8.2.0896: crash when calling searchcount() with a string Commit: https://github.com/vim/vim/commit/14681627f39421cce289345d4ec9927c10fa3b1c Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 3 22:57:39 2020 +0200 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 https://github.com/vim/vim/issues/6192)
author Bram Moolenaar <Bram@vim.org>
date Wed, 03 Jun 2020 23:00:03 +0200
parents a126f643d566
children 1260b27535b5
comparison
equal deleted inserted replaced
20684:635e76ab3722 20685:4c66962d322b
3173 long timeout UNUSED) 3173 long timeout UNUSED)
3174 { 3174 {
3175 int save_ws = p_ws; 3175 int save_ws = p_ws;
3176 int wraparound = FALSE; 3176 int wraparound = FALSE;
3177 pos_T p = (*pos); 3177 pos_T p = (*pos);
3178 static pos_T lastpos = {0, 0, 0}; 3178 static pos_T lastpos = {0, 0, 0};
3179 static int cur = 0; 3179 static int cur = 0;
3180 static int cnt = 0; 3180 static int cnt = 0;
3181 static int exact_match = FALSE; 3181 static int exact_match = FALSE;
3182 static int incomplete = 0; 3182 static int incomplete = 0;
3183 static int last_maxcount = SEARCH_STAT_DEF_MAX_COUNT; 3183 static int last_maxcount = SEARCH_STAT_DEF_MAX_COUNT;
4070 if (shortmess(SHM_SEARCHCOUNT)) // 'shortmess' contains 'S' flag 4070 if (shortmess(SHM_SEARCHCOUNT)) // 'shortmess' contains 'S' flag
4071 recompute = TRUE; 4071 recompute = TRUE;
4072 4072
4073 if (argvars[0].v_type != VAR_UNKNOWN) 4073 if (argvars[0].v_type != VAR_UNKNOWN)
4074 { 4074 {
4075 dict_T *dict = argvars[0].vval.v_dict; 4075 dict_T *dict;
4076 dictitem_T *di; 4076 dictitem_T *di;
4077 listitem_T *li; 4077 listitem_T *li;
4078 int error = FALSE; 4078 int error = FALSE;
4079 4079
4080 if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL)
4081 {
4082 emsg(_(e_dictreq));
4083 return;
4084 }
4085 dict = argvars[0].vval.v_dict;
4080 di = dict_find(dict, (char_u *)"timeout", -1); 4086 di = dict_find(dict, (char_u *)"timeout", -1);
4081 if (di != NULL) 4087 if (di != NULL)
4082 { 4088 {
4083 timeout = (long)tv_get_number_chk(&di->di_tv, &error); 4089 timeout = (long)tv_get_number_chk(&di->di_tv, &error);
4084 if (error) 4090 if (error)