summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-06-26 22:17:35 +0200
committerBram Moolenaar <Bram@vim.org>2021-06-26 22:17:35 +0200
commite3ffaa6b7c2d53ab53da933ec91382d003cf9a12 (patch)
tree96458eb6d1bc525e9030bb54a22f1680d8eb5e2f
parent015cf103115f9a0380ae3e3e85a77792cfe87d49 (diff)
downloadvim-git-e3ffaa6b7c2d53ab53da933ec91382d003cf9a12.tar.gz
patch 8.2.3059: Vim9: memory leak when using lambdav8.2.3059
Problem: Vim9: memory leak when using lambda. Solution: Do not store the default value strings when skipping.
-rw-r--r--src/userfunc.c37
-rw-r--r--src/version.c2
2 files changed, 22 insertions, 17 deletions
diff --git a/src/userfunc.c b/src/userfunc.c
index 3321f089c..c8d08bb45 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -198,7 +198,7 @@ get_function_args(
ga_init2(newargs, (int)sizeof(char_u *), 3);
if (argtypes != NULL)
ga_init2(argtypes, (int)sizeof(char_u *), 3);
- if (default_args != NULL)
+ if (!skip && default_args != NULL)
ga_init2(default_args, (int)sizeof(char_u *), 3);
if (varargs != NULL)
@@ -289,24 +289,27 @@ get_function_args(
expr = p;
if (eval1(&p, &rettv, NULL) != FAIL)
{
- if (ga_grow(default_args, 1) == FAIL)
- goto err_ret;
-
- // trim trailing whitespace
- while (p > expr && VIM_ISWHITE(p[-1]))
- p--;
- c = *p;
- *p = NUL;
- expr = vim_strsave(expr);
- if (expr == NULL)
+ if (!skip)
{
+ if (ga_grow(default_args, 1) == FAIL)
+ goto err_ret;
+
+ // trim trailing whitespace
+ while (p > expr && VIM_ISWHITE(p[-1]))
+ p--;
+ c = *p;
+ *p = NUL;
+ expr = vim_strsave(expr);
+ if (expr == NULL)
+ {
+ *p = c;
+ goto err_ret;
+ }
+ ((char_u **)(default_args->ga_data))
+ [default_args->ga_len] = expr;
+ default_args->ga_len++;
*p = c;
- goto err_ret;
}
- ((char_u **)(default_args->ga_data))
- [default_args->ga_len] = expr;
- default_args->ga_len++;
- *p = c;
}
else
mustend = TRUE;
@@ -357,7 +360,7 @@ get_function_args(
err_ret:
if (newargs != NULL)
ga_clear_strings(newargs);
- if (default_args != NULL)
+ if (!skip && default_args != NULL)
ga_clear_strings(default_args);
return FAIL;
}
diff --git a/src/version.c b/src/version.c
index 59f84d446..7fbd6d0b1 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3059,
+/**/
3058,
/**/
3057,