To: vim_dev@googlegroups.com Subject: Patch 8.2.0896 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0896 Problem: Crash when calling searchcount() with a string. Solution: Check the argument is a dict. (closes #6192) Files: src/search.c, src/testdir/test_search_stat.vim *** ../vim-8.2.0895/src/search.c 2020-06-02 22:06:16.785668534 +0200 --- src/search.c 2020-06-03 22:52:32.898257326 +0200 *************** *** 3175,3181 **** int save_ws = p_ws; int wraparound = FALSE; pos_T p = (*pos); ! static pos_T lastpos = {0, 0, 0}; static int cur = 0; static int cnt = 0; static int exact_match = FALSE; --- 3175,3181 ---- int save_ws = p_ws; int wraparound = FALSE; pos_T p = (*pos); ! static pos_T lastpos = {0, 0, 0}; static int cur = 0; static int cnt = 0; static int exact_match = FALSE; *************** *** 4072,4082 **** if (argvars[0].v_type != VAR_UNKNOWN) { ! dict_T *dict = argvars[0].vval.v_dict; dictitem_T *di; listitem_T *li; int error = FALSE; di = dict_find(dict, (char_u *)"timeout", -1); if (di != NULL) { --- 4072,4088 ---- if (argvars[0].v_type != VAR_UNKNOWN) { ! 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) { *** ../vim-8.2.0895/src/testdir/test_search_stat.vim 2020-06-02 22:06:16.785668534 +0200 --- src/testdir/test_search_stat.vim 2020-06-03 22:56:04.361306510 +0200 *************** *** 259,264 **** --- 259,268 ---- bwipe! endfunc + func Test_searchcount_fails() + call assert_fails('echo searchcount("boo!")', 'E715:') + endfunc + func Test_search_stat_foldopen() CheckScreendump *** ../vim-8.2.0895/src/version.c 2020-06-03 22:15:41.331159342 +0200 --- src/version.c 2020-06-03 22:53:32.437990685 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 896, /**/ -- Edison's greatest achievement came in 1879, when he invented the electric company. Edison's design was a brilliant adaptation of the simple electrical circuit: the electric company sends electricity through a wire to a customer, then immediately gets the electricity back through another wire /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///