changeset 22015:d8065205ea82 v8.2.1557

patch 8.2.1557: crash in :vimgrep when started as "vim -n" Commit: https://github.com/vim/vim/commit/997cd1a17f030d004b334d17cf1c1c57050c9906 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 31 22:16:08 2020 +0200 patch 8.2.1557: crash in :vimgrep when started as "vim -n" Problem: Crash in :vimgrep when started as "vim -n". (Raul Segura) Solution: Check mfp pointer. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6827)
author Bram Moolenaar <Bram@vim.org>
date Mon, 31 Aug 2020 22:30:04 +0200
parents 023d9e265ff0
children 74fac2b83733
files src/quickfix.c src/testdir/test_quickfix.vim src/version.c
diffstat 3 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -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);
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -2833,6 +2833,21 @@ func Test_vimgrep_with_no_last_search_pa
   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')
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1557,
+/**/
     1556,
 /**/
     1555,