0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.3133: Vim9: memory leak when add() fails

Problem:    Vim9: memory leak when add() fails.
Solution:   Allocate listitem_T after type check.
This commit is contained in:
Bram Moolenaar 2021-07-09 19:17:55 +02:00
parent 6bcb18253a
commit 90fba5627b
2 changed files with 4 additions and 1 deletions

View File

@ -602,11 +602,12 @@ list_append(list_T *l, listitem_T *item)
int int
list_append_tv(list_T *l, typval_T *tv) 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 if (l->lv_type != NULL && l->lv_type->tt_member != NULL
&& check_typval_arg_type(l->lv_type->tt_member, tv, 0) == FAIL) && check_typval_arg_type(l->lv_type->tt_member, tv, 0) == FAIL)
return FAIL; return FAIL;
li = listitem_alloc();
if (li == NULL) if (li == NULL)
return FAIL; return FAIL;
copy_tv(tv, &li->li_tv); copy_tv(tv, &li->li_tv);

View File

@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3133,
/**/ /**/
3132, 3132,
/**/ /**/