patch 8.2.3133: Vim9: memory leak when add() fails
Problem: Vim9: memory leak when add() fails.
Solution: Allocate listitem_T after type check.
diff --git a/src/list.c b/src/list.c
index 9aec823..d138d86 100644
--- a/src/list.c
+++ b/src/list.c
@@ -602,11 +602,12 @@
int
list_append_tv(list_T *l, typval_T *tv)
{
- listitem_T *li = listitem_alloc();
+ listitem_T *li;
if (l->lv_type != NULL && l->lv_type->tt_member != NULL
&& check_typval_arg_type(l->lv_type->tt_member, tv, 0) == FAIL)
return FAIL;
+ li = listitem_alloc();
if (li == NULL)
return FAIL;
copy_tv(tv, &li->li_tv);