[vim/vim] Fix memory leak in `expand_findfunc()` in `src/ex_docmd.c` (PR #19564)

0 views
Skip to first unread message

Huihui Huang

unread,
9:29 AM (10 hours ago) 9:29 AM
to vim/vim, Subscribed

Problem

In expand_findfunc(), the list l is allocated by call_findfunc() (lines 7076–7079):

l = call_findfunc(pat, VVAL_TRUE);

if (l == NULL)
    return FAIL;

However, there are early-return paths after l is allocated (lines 7081–7087):

len = list_len(l);
if (len == 0)        // empty List
    return FAIL;

*files = ALLOC_MULT(char_u *, len);
if (*files == NULL)
    return FAIL;

On these failure paths, l is not freed. Since list_free(l) is only called on the success path near the end of the function, l is leaked when returning early.

Solution

Free l before returning on error paths. The fix is included in this commit.


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

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

Commit Summary

  • 69ad24c Fix: memory leak in expand_findfunc() in src/ex_docmd.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/19564@github.com>

Christian Brabandt

unread,
3:41 PM (4 hours ago) 3:41 PM
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19564)

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/19564/c3993418636@github.com>

Christian Brabandt

unread,
3:49 PM (4 hours ago) 3:49 PM
to vim/vim, Subscribed

Closed #19564 via 648240f.


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/19564/issue_event/23238949871@github.com>

Reply all
Reply to author
Forward
0 new messages