summaryrefslogtreecommitdiff
path: root/src/search.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-06-03 22:57:39 +0200
committerBram Moolenaar <Bram@vim.org>2020-06-03 22:57:39 +0200
commit14681627f39421cce289345d4ec9927c10fa3b1c (patch)
treef7ba64b787e34d2fc1438a9546c3b9733d8b0802 /src/search.c
parent408c23b0794540ee3c568a1569f21406c5ed3ab8 (diff)
downloadvim-git-14681627f39421cce289345d4ec9927c10fa3b1c.tar.gz
patch 8.2.0896: crash when calling searchcount() with a stringv8.2.0896
Problem: Crash when calling searchcount() with a string. Solution: Check the argument is a dict. (closes #6192)
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/search.c b/src/search.c
index 210806258..7346383fc 100644
--- a/src/search.c
+++ b/src/search.c
@@ -3175,7 +3175,7 @@ update_search_stat(
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;
@@ -4072,11 +4072,17 @@ f_searchcount(typval_T *argvars, typval_T *rettv)
if (argvars[0].v_type != VAR_UNKNOWN)
{
- dict_T *dict = argvars[0].vval.v_dict;
+ dict_T *dict;
dictitem_T *di;
listitem_T *li;
int 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 = dict_find(dict, (char_u *)"timeout", -1);
if (di != NULL)
{