[vim/vim] Fix memory leak in `heredoc_get()` in `src/evalvars.c` (PR #19563)

1 view
Skip to first unread message

Huihui Huang

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

Problem

In heredoc_get(), a list is allocated to store heredoc lines (lines 871–873):

l = list_alloc();
if (l == NULL)
    return NULL;

Later, when vim9compile is enabled, if compile_all_expr_in_str() fails the function returns early (lines 948–953):

if (compile_all_expr_in_str(str, evalstr, cctx) == FAIL)
{
    vim_free(theline);
    vim_free(text_indent);
    return FAIL;
}

On this early-return path, the allocated list l is not freed, resulting in a memory leak.

Solution

Free l before returning when compile_all_expr_in_str() fails. 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/19563

Commit Summary

  • 89868ba Fix: memory leak in heredoc_get() in src/evalvars.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/19563@github.com>

Christian Brabandt

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

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/19563/c3993389699@github.com>

Christian Brabandt

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

Closed #19563 via 7d1e0a7.


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/19563/issue_event/23238745400@github.com>

Reply all
Reply to author
Forward
0 new messages