]> granicus.if.org Git - vim/commitdiff
patch 8.2.1557: crash in :vimgrep when started as "vim -n" v8.2.1557
authorBram Moolenaar <Bram@vim.org>
Mon, 31 Aug 2020 20:16:08 +0000 (22:16 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 31 Aug 2020 20:16:08 +0000 (22:16 +0200)
Problem:    Crash in :vimgrep when started as "vim -n". (Raul Segura)
Solution:   Check mfp pointer. (Yegappan Lakshmanan, closes #6827)

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

index 99b0169ea5c39a028bbcd48066b3946b59520cad..f8ff7765ed3e4faecb04733e7e3cb10a732453d0 100644 (file)
@@ -6022,7 +6022,7 @@ vgr_process_args(
     static int
 existing_swapfile(buf_T *buf)
 {
-    if (buf->b_ml.ml_mfp != NULL)
+    if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL)
     {
        char_u *fname = buf->b_ml.ml_mfp->mf_fname;
        size_t len = STRLEN(fname);
index c35b11c669dad0d365da5ce74b4e4047fada8f15..8faf69a318a0dea221510701bd8de71b6539accc 100644 (file)
@@ -2833,6 +2833,21 @@ func Test_vimgrep_with_no_last_search_pat()
   call delete('Xresult')
 endfunc
 
+" Test vimgrep without swap file
+func Test_vimgrep_without_swap_file()
+  let lines =<< trim [SCRIPT]
+    vimgrep grep test_c*
+    call writefile(['done'], 'Xresult')
+    qall!
+  [SCRIPT]
+  call writefile(lines, 'Xscript')
+  if RunVim([], [], '--clean -n -S Xscript Xscript')
+    call assert_equal(['done'], readfile('Xresult'))
+  endif
+  call delete('Xscript')
+  call delete('Xresult')
+endfunc
+
 func Test_vimgrep_existing_swapfile()
   call writefile(['match apple with apple'], 'Xapple')
   call writefile(['swapfile'], '.Xapple.swp')
index 022c90acbf2c3c622574d56f5826d0be909fab49..214ee2a8ed0a222707d3d6eb513fe0c433f69e10 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1557,
 /**/
     1556,
 /**/