Commit: patch memory leak in list_extend_func() in list.c

1 view
Skip to first unread message

Christian Brabandt

unread,
Mar 8, 2026, 3:46:59 PMMar 8
to vim...@googlegroups.com
patch memory leak in list_extend_func() in list.c

Commit: https://github.com/vim/vim/commit/7ed37dc53409331cd9e7e0e10238651f7bca2672
Author: Huihui Huang <625...@qq.com>
Date: Sun Mar 8 19:37:22 2026 +0000

patch memory leak in list_extend_func() in list.c

Problem: memory leak in list_extend_func() in list.c
Solution: Free l1 on early return (Huihui Huang)

closes: #19572

Signed-off-by: Huihui Huang <625...@qq.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/list.c b/src/list.c
index 310d8516b..cd12bcb0a 100644
--- a/src/list.c
+++ b/src/list.c
@@ -3025,8 +3025,7 @@ list_extend_func(
{
before = (long)tv_get_number_chk(&argvars[2], &error);
if (error)
- return; // type error; errmsg already given
-
+ goto cleanup; // type error; errmsg already given
if (before == l1->lv_len)
item = NULL;
else
@@ -3035,7 +3034,7 @@ list_extend_func(
if (item == NULL)
{
semsg(_(e_list_index_out_of_range_nr), before);
- return;
+ goto cleanup;
}
}
}
@@ -3043,7 +3042,7 @@ list_extend_func(
item = NULL;
if (type != NULL && check_typval_arg_type(
type, &argvars[1], func_name, 2) == FAIL)
- return;
+ goto cleanup;
list_extend(l1, l2, item);

if (is_new)
@@ -3054,6 +3053,11 @@ list_extend_func(
}
else
copy_tv(&argvars[0], rettv);
+ return;
+
+cleanup:
+ if (is_new)
+ list_unref(l1);
}
}

diff --git a/src/version.c b/src/version.c
index 5fd399c97..4ad7d6aee 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 121,
/**/
120,
/**/
Reply all
Reply to author
Forward
0 new messages