]> granicus.if.org Git - vim/commitdiff
patch 8.2.2101: Vim9: memory leak when literal dict has an error v8.2.2101
authorBram Moolenaar <Bram@vim.org>
Sun, 6 Dec 2020 15:03:55 +0000 (16:03 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 6 Dec 2020 15:03:55 +0000 (16:03 +0100)
Problem:    Vim9: memory leak when literal dict has an error and when an
            expression is not complete.
Solution:   Clear the typval and the growarray.

src/dict.c
src/version.c
src/vim9compile.c

index 311b0038d1cf1ce495c8ebe1d0e649add8460b85..5581a5571bc0263981cace0cf14980d261421145 100644 (file)
@@ -929,6 +929,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
                if (**arg != ']')
                {
                    emsg(_(e_missing_matching_bracket_after_dict_key));
+                   clear_tv(&tvkey);
                    return FAIL;
                }
                ++*arg;
index 2754d2f72279a49c0413037152439d2dc7aa1ce4..56cea2657d038ef9e87c1af6a62592f3fb22185c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2101,
 /**/
     2100,
 /**/
index f02ea60cccde24d4b8d4c4baa71756ecc9a8fc22..bfa54fea766ba5f726ee9b2d1a7be69cfba34c29 100644 (file)
@@ -4392,7 +4392,10 @@ compile_and_or(
            // eval the next expression
            *arg = skipwhite(p + 2);
            if (may_get_next_line_error(p + 2, arg, cctx) == FAIL)
+           {
+               ga_clear(&end_ga);
                return FAIL;
+           }
 
            if ((opchar == '|' ? compile_expr3(arg, cctx, ppconst)
                                  : compile_expr4(arg, cctx, ppconst)) == FAIL)