summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-09 23:20:20 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-09 23:20:20 +0200
commit3b6a6eb7b4e0ac5b75dd2518bd27bce2b13298a3 (patch)
tree9d54c87e593b7591d54b97db482b5c74e7d44047
parent09689a02840be40fa7bb10b1921fb5bc5b2908f1 (diff)
patch 8.2.0726: Vim9: leaking memory when calling not compiled :def functionv8.2.0726
Problem: Vim9: leaking memory when calling not compiled :def function. Solution: Check if function is compiled earlier.
-rw-r--r--src/version.c2
-rw-r--r--src/vim9execute.c10
2 files changed, 7 insertions, 5 deletions
diff --git a/src/version.c b/src/version.c
index bc93675ab4..ef7dedb980 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 726,
+/**/
725,
/**/
724,
diff --git a/src/vim9execute.c b/src/vim9execute.c
index bfa24928a8..4d4df0ab60 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -665,10 +665,6 @@ call_def_function(
// Like STACK_TV_VAR but use the outer scope
#define STACK_OUT_TV_VAR(idx) (((typval_T *)ectx.ec_outer_stack->ga_data) + ectx.ec_outer_frame + STACK_FRAME_SIZE + idx)
- CLEAR_FIELD(ectx);
- ga_init2(&ectx.ec_stack, sizeof(typval_T), 500);
- if (ga_grow(&ectx.ec_stack, 20) == FAIL)
- return FAIL;
{
// Check the function was compiled, it is postponed in ex_vim9script().
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
@@ -676,8 +672,12 @@ call_def_function(
if (dfunc->df_instr == NULL)
return FAIL;
}
- ectx.ec_dfunc_idx = ufunc->uf_dfunc_idx;
+ CLEAR_FIELD(ectx);
+ ectx.ec_dfunc_idx = ufunc->uf_dfunc_idx;
+ ga_init2(&ectx.ec_stack, sizeof(typval_T), 500);
+ if (ga_grow(&ectx.ec_stack, 20) == FAIL)
+ return FAIL;
ga_init2(&ectx.ec_trystack, sizeof(trycmd_T), 10);
// Put arguments on the stack.