diff src/vim9compile.c @ 20534:ae758aa4ee5e v8.2.0821

patch 8.2.0821: Vim9: memory leak in expr test Commit: https://github.com/vim/vim/commit/45a1508a229b1d1d2eb79cabe55a183dc18fd040 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 25 00:28:33 2020 +0200 patch 8.2.0821: Vim9: memory leak in expr test Problem: Vim9: memory leak in expr test. Solution: Do not decrement the length of the list of functions if the current function is not at the end.
author Bram Moolenaar <Bram@vim.org>
date Mon, 25 May 2020 00:30:03 +0200
parents cb4831fa7e25
children 9f921ba86d05
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -1443,7 +1443,7 @@ generate_CALL(cctx_T *cctx, ufunc_T *ufu
 	    }
 	}
 	if (ufunc->uf_dfunc_idx == UF_TO_BE_COMPILED)
-	    if (compile_def_function(ufunc, TRUE, cctx) == FAIL)
+	    if (compile_def_function(ufunc, TRUE, NULL) == FAIL)
 		return FAIL;
     }
 
@@ -6776,9 +6776,11 @@ erret:
 	    delete_instr(((isn_T *)instr->ga_data) + idx);
 	ga_clear(instr);
 
+	// if using the last entry in the table we might as well remove it
+	if (!dfunc->df_deleted
+			    && ufunc->uf_dfunc_idx == def_functions.ga_len - 1)
+	    --def_functions.ga_len;
 	ufunc->uf_dfunc_idx = UF_NOT_COMPILED;
-	if (!dfunc->df_deleted)
-	    --def_functions.ga_len;
 
 	while (cctx.ctx_scope != NULL)
 	    drop_scope(&cctx);