[vim/vim] Fix: memory leak in `eval8` in `src/eval.c` (PR #19819)

0 views
Skip to first unread message

Huihui Huang

unread,
Mar 25, 2026, 7:47:36 AM (23 hours ago) Mar 25
to vim/vim, Subscribed

Problem

In eval8() located in src/eval.c, parse_type() is called at line 4837 to parse a <type> cast in Vim9 script, allocating type objects into type_list:

want_type = parse_type(arg, &type_list, NULL, NULL, TRUE);

The cleanup call clear_type_list(&type_list) at line 4887 is only reached when want_type != NULL && evaluate:

if (want_type != NULL && evaluate)
{
    if (res == OK)
    {
        // ... type checking logic ...
    }
    clear_type_list(&type_list);
}

When want_type != NULL but evaluate is false (the expression is being parsed but not evaluated), the entire block is skipped and clear_type_list() is never called. The types allocated by parse_type() into type_list are leaked.

Solution

Change the outer condition from want_type != NULL && evaluate to just want_type != NULL, so that clear_type_list(&type_list) is always called when types were allocated. The evaluate check is moved inward to guard only the type-checking logic that depends on it. 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/19819

Commit Summary

  • 4b60c75 Fix: memory leak in eval8 in src/eval.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/19819@github.com>

Christian Brabandt

unread,
Mar 25, 2026, 3:27:10 PM (15 hours ago) Mar 25
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19819)

thanks


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/19819/c4129199134@github.com>

Christian Brabandt

unread,
Mar 25, 2026, 3:31:05 PM (15 hours ago) Mar 25
to vim/vim, Subscribed

Closed #19819 via e2cf84d.


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/19819/issue_event/23904732206@github.com>

Reply all
Reply to author
Forward
0 new messages