patch 9.2.0803: Memory leak on alloc failure with taglist/gettagstack()
Commit:
https://github.com/vim/vim/commit/aa8c663deb870464ee0da8de6d5a65c613038a1c
Author: Yasuhiro Matsumoto <
matt...@gmail.com>
Date: Sat Jul 18 14:41:24 2026 +0000
patch 9.2.0803: Memory leak on alloc failure with taglist/gettagstack()
Problem: Memory leak on alloc failure with taglist/gettagstack()
Solution: Free the dict on list_append_dict() failure
(Yasuhiro Matsumoto).
taglist() and gettagstack() ignored the append failure and leaked the
dict, and continued populating an orphaned dict. Free it and stop.
closes: #20745
related: #20668
Signed-off-by: Yasuhiro Matsumoto <
matt...@gmail.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/src/tag.c b/src/tag.c
index 0e9d9344b..cd068043d 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -4450,7 +4450,12 @@ get_tags(list_T *list, char_u *pat, char_u *buf_fname)
break;
}
if (list_append_dict(list, dict) == FAIL)
+ {
ret = FAIL;
+ dict_unref(dict);
+ vim_free(matches[i]);
+ continue;
+ }
full_fname = tag_full_fname(&tp);
if (add_tag_field(dict, "name", tp.tagname, tp.tagname_end) == FAIL
@@ -4564,7 +4569,11 @@ get_tagstack(win_T *wp, dict_T *retdict)
{
if ((d = dict_alloc_id(aid_tagstack_details)) == NULL)
return;
- list_append_dict(l, d);
+ if (list_append_dict(l, d) == FAIL)
+ {
+ dict_unref(d);
+ return;
+ }
get_tag_details(&wp->w_tagstack[i], d);
}
diff --git a/src/version.c b/src/version.c
index c64e48f08..29624fe21 100644
--- a/src/version.c
+++ b/src/version.c
@@ -759,6 +759,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 803,
/**/
802,
/**/