[vim/vim] :vimgrep will crash if vim was started with "-n" (no swap) argument (#6827)

6 views
Skip to first unread message

Raul Segura

unread,
Aug 31, 2020, 2:46:46 PM8/31/20
to vim/vim, Subscribed

Vim will crash if started with "-n" argument, and a :vimgrep command is executed with a pattern that does match at least one of the scanned files.

To Reproduce

  1. Run gvim -n.
  2. Type :vimgrep /a/ *.
  3. Wait for gvim to scan the files, gvim window will just disappear right before opening the first match returning a "Segmentation fault" error.

Expected behavior
Command is expected to return a list with several files (in quickfix window) and open the first one of them.

Environment:

  • Vim version: 8.2.1384
  • OS: Windows 10 1909
  • Compiler: MinGW cross compiler on Cygwin

The bug was introduced by v8.2.1384, and still present on v8.2.1548


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

lacygoill

unread,
Aug 31, 2020, 3:02:01 PM8/31/20
to vim/vim, Subscribed

lacygoill

unread,
Aug 31, 2020, 3:08:27 PM8/31/20
to vim/vim, Subscribed

cc @yegappan via #6638

lacygoill

unread,
Aug 31, 2020, 3:10:11 PM8/31/20
to vim/vim, Subscribed

cc @yegappan via #6638

Sorry I checked the wrong commit; 8.2.1383 instead of 8.2.1384.

Yegappan Lakshmanan

unread,
Aug 31, 2020, 3:41:13 PM8/31/20
to vim_dev, reply+ACY5DGF2V4MPUMTYQS...@reply.github.com, vim/vim, Subscribed
Hi,

On Mon, Aug 31, 2020 at 12:10 PM lacygoill <vim-dev...@256bit.org> wrote:

cc @yegappan via #6638

Sorry I checked the wrong commit; 8.2.1383 instead of 8.2.1384.



The if condition in the existing_swapfile() function needs to be changed as below:

    if ((buf->b_ml.ml_mfp != NULL) && (buf->b_ml.ml_mfp->mf_fname != NULL))

- Yegappan

vim-dev ML

unread,
Aug 31, 2020, 3:41:32 PM8/31/20
to vim/vim, vim-dev ML, Your activity

Hi,

On Mon, Aug 31, 2020 at 12:10 PM lacygoill <vim-dev...@256bit.org>
wrote:

> cc @yegappan <https://github.com/yegappan> via #6638
> <https://github.com/vim/vim/pull/6638>

>
> Sorry I checked the wrong commit; 8.2.1383 instead of 8.2.1384.
>
>
>
The if condition in the existing_swapfile() function needs to be changed as
below:

if ((buf->b_ml.ml_mfp != NULL) && (buf->b_ml.ml_mfp->mf_fname != NULL))

- Yegappan

lacygoill

unread,
Aug 31, 2020, 3:48:34 PM8/31/20
to vim/vim, vim-dev ML, Comment

Can confirm that this patch fixes the issue:

diff --git a/src/quickfix.c b/src/quickfix.c
index 99b0169ea..99847db13 100644
--- 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);

Thank you @yegappan.


You are receiving this because you commented.

Bram Moolenaar

unread,
Aug 31, 2020, 4:16:38 PM8/31/20
to vim/vim, vim-dev ML, Comment

Closed #6827 via 997cd1a.


You are receiving this because you commented.

Reply all
Reply to author
Forward
0 new messages