diff src/vim9compile.c @ 24492:cca0a1b4e878 v8.2.2786

patch 8.2.2786: Vim9: memory leak when using :s with expression Commit: https://github.com/vim/vim/commit/4f2df37a0d297a0f40ff15f8ce31285c7b529bcd Author: Bram Moolenaar <Bram@vim.org> Date: Mon Apr 19 21:06:31 2021 +0200 patch 8.2.2786: Vim9: memory leak when using :s with expression Problem: Vim9: memory leak when using :s with expression. Solution: Clean up the instruction list.
author Bram Moolenaar <Bram@vim.org>
date Mon, 19 Apr 2021 21:15:03 +0200
parents 08050e45bd06
children bfa495227ac6
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -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: