]> granicus.if.org Git - vim/commitdiff
patch 8.2.2786: Vim9: memory leak when using :s with expression v8.2.2786
authorBram Moolenaar <Bram@vim.org>
Mon, 19 Apr 2021 19:06:31 +0000 (21:06 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 19 Apr 2021 19:06:31 +0000 (21:06 +0200)
Problem:    Vim9: memory leak when using :s with expression.
Solution:   Clean up the instruction list.

src/version.c
src/vim9compile.c

index 22a2751bd3802738f863a718238b223f884b6a62..834196d83b82da8e6d538895aa253c679d7914dc 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2786,
 /**/
     2785,
 /**/
index 027f79d95cf775efcfcf61fc750db770f05b7256..0695879e32f583cbe2e7843f2781413ce3ff3409 100644 (file)
@@ -9416,8 +9416,15 @@ delete_instr(isn_T *isn)
            break;
 
        case ISN_SUBSTITUTE:
-           vim_free(isn->isn_arg.subs.subs_cmd);
-           vim_free(isn->isn_arg.subs.subs_instr);
+           {
+               int     idx;
+               isn_T   *list = isn->isn_arg.subs.subs_instr;
+
+               vim_free(isn->isn_arg.subs.subs_cmd);
+               for (idx = 0; list[idx].isn_type != ISN_FINISH; ++idx)
+                   delete_instr(list + idx);
+               vim_free(list);
+           }
            break;
 
        case ISN_LOADS: