]> granicus.if.org Git - vim/commitdiff
patch 8.0.1750: crash when clearing loccation list in autocommand v8.0.1750
authorBram Moolenaar <Bram@vim.org>
Mon, 23 Apr 2018 19:29:48 +0000 (21:29 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 23 Apr 2018 19:29:48 +0000 (21:29 +0200)
Problem:    Crash when clearing loccation list in autocommand.
Solution:   Check if "qi" equals "ql_info". (Yegappan Lakshmanan)

src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index 39e3913c0969f78f13121619807c0b82ae80d592..6142825e3be09e3dbdde235e372aa865d51aed0f 100644 (file)
@@ -5897,7 +5897,6 @@ ex_helpgrep(exarg_T *eap)
     char_u     *lang;
 #endif
     qf_info_T  *qi = &ql_info;
-    qf_info_T  *save_qi;
     int                new_qi = FALSE;
     win_T      *wp;
     char_u     *au_name =  NULL;
@@ -5951,9 +5950,6 @@ ex_helpgrep(exarg_T *eap)
        }
     }
 
-    /* Autocommands may change the list. Save it for later comparison */
-    save_qi = qi;
-
     regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING);
     regmatch.rm_ic = FALSE;
     if (regmatch.regprog != NULL)
@@ -6086,7 +6082,7 @@ ex_helpgrep(exarg_T *eap)
     {
        apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
                                               curbuf->b_fname, TRUE, curbuf);
-       if (!new_qi && qi != save_qi && qf_find_buf(qi) == NULL)
+       if (!new_qi && qi != &ql_info && qf_find_buf(qi) == NULL)
            /* autocommands made "qi" invalid */
            return;
     }
index b0e14e6ad026c1d3075adcc4ebb8bd6baea7e068..12bfe32278fe348f30a9c8170bf829a5f5d41534 100644 (file)
@@ -3175,3 +3175,17 @@ func Test_vimgrep_autocmd()
   call delete('Xtest2.txt')
   call setqflist([], 'f')
 endfunc
+
+" The following test used to crash Vim
+func Test_lhelpgrep_autocmd()
+  lhelpgrep quickfix
+  autocmd QuickFixCmdPost * call setloclist(0, [], 'f')
+  lhelpgrep buffer
+  call assert_equal('help', &filetype)
+  call assert_equal(0, getloclist(0, {'nr' : '$'}).nr)
+  lhelpgrep tabpage
+  call assert_equal('help', &filetype)
+  call assert_equal(1, getloclist(0, {'nr' : '$'}).nr)
+  au! QuickFixCmdPost
+  new | only
+endfunc
index 55892048d054a724d46584f6f48ce29c2d8fbb64..123db5b675c421e974fee097f0d58235e62d7155 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1750,
 /**/
     1749,
 /**/