[vim/vim] Add out-of-memory checks to quickfix.c (PR #19528)

10 views
Skip to first unread message

John Marriott

unread,
Feb 27, 2026, 5:24:10 PM (3 days ago) Feb 27
to vim/vim, Subscribed

This PR adds out-of-memory checks to quickfix.c in functions qf_get_fnum() and qf_push_dir().

Cheers
John


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19528

Commit Summary

  • 1d3823e Add out-of-memory checks to quickfix.c

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19528@github.com>

Christian Brabandt

unread,
Feb 28, 2026, 12:57:21 PM (2 days ago) Feb 28
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In src/quickfix.c:

> @@ -2823,6 +2825,8 @@ qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, int is_file_stack)
 	    vim_free((*stackptr)->dirname);
 	    (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf,
 		    TRUE);
+	    if ((*stackptr)->dirname == NULL)
+		return NULL;

Isn't this part leaking memory? I think it should be similar to this:

if ((*stackptr)->dirname == NULL)
{
    vim_free(ds_new->dirname);
    vim_free(ds_new);
    return NULL;
}


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19528/review/3870644952@github.com>

John Marriott

unread,
Feb 28, 2026, 5:04:03 PM (2 days ago) Feb 28
to vim/vim, Subscribed

@basilisk0315 commented on this pull request.


In src/quickfix.c:

> @@ -2823,6 +2825,8 @@ qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, int is_file_stack)
 	    vim_free((*stackptr)->dirname);
 	    (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf,
 		    TRUE);
+	    if ((*stackptr)->dirname == NULL)
+		return NULL;

I think you're on the right track, but I think more like this:

	while (ds_new)
	{
	    char_u  *dirname;

	    
dirname = concat_fnames(ds_new->dirname, dirbuf
, TRUE);
	    if (dirname == NULL)
	    {
		    // pop the new element from the stack and free it
		    ds_ptr = *stackptr;
		    *stackptr = (*stackptr)->next;
		    vim_free(ds_ptr);

		    return NULL;
	    }
	    if (mch_isdir(dirname) == TRUE)
	    {
		    vim_free((*stackptr)->dirname);
		    (*stackptr)->dirname = dirname;
		    break;
	    }

	    ds_new = ds_new->next;
	}


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19528/review/3870842835@github.com>

John Marriott

unread,
Mar 1, 2026, 5:12:32 PM (yesterday) Mar 1
to vim/vim, Push

@basilisk0315 pushed 1 commit.

  • 2066731 Improve error handling and slightly refactor for clarity


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19528/before/1d3823e8e50de4f74a6c56b13624d5122135d203/after/2066731427bdeb983e20922c7157c56815258d5b@github.com>

Christian Brabandt

unread,
1:49 PM (7 hours ago) 1:49 PM
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19528)

alright, thanks


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19528/c3986211924@github.com>

Christian Brabandt

unread,
1:49 PM (7 hours ago) 1:49 PM
to vim/vim, Subscribed

Closed #19528 via 0155401.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19528/issue_event/23202509687@github.com>

Reply all
Reply to author
Forward
0 new messages