[vim/vim] fix memory leaks on allocation-failure paths (PR #20745)

1 view
Skip to first unread message

mattn

unread,
Jul 10, 2026, 3:00:03 PM (24 hours ago) Jul 10
to vim/vim, Subscribed

Several functions leaked a freshly allocated object on an allocation-failure path: they ignored the return of list_append_dict() / dict_add_list() / dict_add_dict() (leaking the GC-linked dict or list on OOM), returned past a cleanup label, or dropped a string copy when a grow failed. Each now frees the object on the failure path.

Affected: getqflist, getreginfo, taglist/gettagstack, hlget, prop_list, getmatches, menu_getinfo, popup_getoptions, sign_getplaced, job_info, term_getcursor/term_scrape, diff(), complete_info, cmdcomplete_info, two Vim9 compile paths (constant string concat and ga_add_string), and call_func generic type args.

related: #20668


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

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

Commit Summary

  • 1bc6e7a getqflist: free dict on list_append_dict() failure
  • a2bfbf9 vim9: free left string when constant string concat alloc fails
  • ae6185c vim9: free line copy when ga_add_string() fails
  • 2742440 call_func: free generic type args table on name alloc failure
  • 29db5fd getreginfo: free regcontents list when dict_add_list() fails
  • 4930ea9 builtins: free dict/list when append/add fails on alloc
  • 00148e4 taglist/gettagstack: free dict on list_append_dict() failure

File Changes

(18 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20745@github.com>

Reply all
Reply to author
Forward
0 new messages