]> granicus.if.org Git - vim/commitdiff
patch 8.2.3133: Vim9: memory leak when add() fails v8.2.3133
authorBram Moolenaar <Bram@vim.org>
Fri, 9 Jul 2021 17:17:55 +0000 (19:17 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 9 Jul 2021 17:17:55 +0000 (19:17 +0200)
Problem:    Vim9: memory leak when add() fails.
Solution:   Allocate listitem_T after type check.

src/list.c
src/version.c

index 9aec823eef2d3617ff243061d8fca385b41eb582..d138d868cdad8fe3b594e32d2a50587df7668827 100644 (file)
@@ -602,11 +602,12 @@ list_append(list_T *l, listitem_T *item)
     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);
index e2108a025a9ac3ac3aec65fa3bdc55198b5b4ab0..39d8f1455c28871ebfde9059e3c54053ac0d17c3 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3133,
 /**/
     3132,
 /**/