]> granicus.if.org Git - vim/commitdiff
patch 9.0.0322: crash when no errors and 'quickfixtextfunc' is set v9.0.0322
authorBram Moolenaar <Bram@vim.org>
Mon, 29 Aug 2022 19:45:16 +0000 (20:45 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 29 Aug 2022 19:45:16 +0000 (20:45 +0100)
Problem:    Crash when no errors and 'quickfixtextfunc' is set.
Solution:   Do not handle errors if there aren't any.

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

index 78f6880d80206532400303bb47c47583ea0552e3..ab288e0c4d6032ec1e24a4cf94c39c3397f1cad8 100644 (file)
@@ -4761,7 +4761,7 @@ qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid)
     }
 
     // Check if there is anything to display
-    if (qfl != NULL)
+    if (qfl != NULL && qfl->qf_start != NULL)
     {
        char_u          dirname[MAXPATHL];
        int             invalid_val = FALSE;
index 31d36ef1d63c6370675720b453d0faa77cacc237..ee43cb685a3f4fcf358834dd617d0da91f6ec4a2 100644 (file)
@@ -4107,6 +4107,22 @@ func Xgetlist_empty_tests(cchar)
   endif
 endfunc
 
+func Test_empty_list_quickfixtextfunc()
+  " This was crashing.  Can only reproduce by running it in a separate Vim
+  " instance.
+  let lines =<< trim END
+      func s:Func(o)
+              cgetexpr '0'
+      endfunc
+      cope
+      let &quickfixtextfunc = 's:Func'
+      cgetfile [ex
+  END
+  call writefile(lines, 'Xquickfixtextfunc')
+  call RunVim([], [], '-e -s -S Xquickfixtextfunc -c qa')
+  call delete('Xquickfixtextfunc')
+endfunc
+
 func Test_getqflist()
   call Xgetlist_empty_tests('c')
   call Xgetlist_empty_tests('l')
index a1fc74f82ba1a7ac4325e8231b3f1a4bad6becff..be50c4206554e7a19b4041df67c3fbf45e288b79 100644 (file)
@@ -707,6 +707,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    322,
 /**/
     321,
 /**/