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 <625173@qq.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Huihui Huang
2026-03-08 19:37:22 +00:00
committed by Christian Brabandt
parent 123a1e6410
commit 7ed37dc534
2 changed files with 10 additions and 4 deletions
+8 -4
View File
@@ -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);
}
}
+2
View File
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
121,
/**/
120,
/**/