summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-09-05 10:47:13 +0100
committerBram Moolenaar <Bram@vim.org>2022-09-05 10:47:13 +0100
commit31ea6bf530a814991f669122dbc9921117a862c3 (patch)
tree39592c1f3c70d3c2173ad8453a76ea78e97a9e27
parentb40ad4ff148404b1226bea7051278a1c3c79d4f3 (diff)
downloadvim-git-31ea6bf530a814991f669122dbc9921117a862c3.tar.gz
patch 9.0.0382: freeing the wrong string on failurev9.0.0382
Problem: Freeing the wrong string on failure. Solution: Adjust the argument. Reorder the code.
-rw-r--r--src/version.c2
-rw-r--r--src/vim9execute.c11
2 files changed, 8 insertions, 5 deletions
diff --git a/src/version.c b/src/version.c
index 021694b3c..596141307 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 382,
+/**/
381,
/**/
380,
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 3194f872f..08774fee3 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -937,21 +937,22 @@ add_defer_function(char_u *name, int argcount, typval_T *argvars)
if (dfunc->df_defer_var_idx == 0)
{
iemsg("df_defer_var_idx is zero");
- vim_free(func_tv.vval.v_string);
+ vim_free(name);
return FAIL;
}
- func_tv.v_type = VAR_FUNC;
- func_tv.v_lock = 0;
- func_tv.vval.v_string = name;
l = add_defer_item(dfunc->df_defer_var_idx - 1, 1, current_ectx);
if (l == NULL)
{
- vim_free(func_tv.vval.v_string);
+ vim_free(name);
return FAIL;
}
+ func_tv.v_type = VAR_FUNC;
+ func_tv.v_lock = 0;
+ func_tv.vval.v_string = name;
list_set_item(l, 0, &func_tv);
+
for (i = 0; i < argcount; ++i)
list_set_item(l, i + 1, argvars + i);
return OK;