0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.2.3059: Vim9: memory leak when using lambda

Problem:    Vim9: memory leak when using lambda.
Solution:   Do not store the default value strings when skipping.
This commit is contained in:
Bram Moolenaar
2021-06-26 22:17:35 +02:00
parent 015cf10311
commit e3ffaa6b7c
2 changed files with 23 additions and 18 deletions

View File

@@ -198,7 +198,7 @@ get_function_args(
ga_init2(newargs, (int)sizeof(char_u *), 3); ga_init2(newargs, (int)sizeof(char_u *), 3);
if (argtypes != NULL) if (argtypes != NULL)
ga_init2(argtypes, (int)sizeof(char_u *), 3); 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); ga_init2(default_args, (int)sizeof(char_u *), 3);
if (varargs != NULL) if (varargs != NULL)
@@ -288,6 +288,8 @@ get_function_args(
p = skipwhite(p); p = skipwhite(p);
expr = p; expr = p;
if (eval1(&p, &rettv, NULL) != FAIL) if (eval1(&p, &rettv, NULL) != FAIL)
{
if (!skip)
{ {
if (ga_grow(default_args, 1) == FAIL) if (ga_grow(default_args, 1) == FAIL)
goto err_ret; goto err_ret;
@@ -308,6 +310,7 @@ get_function_args(
default_args->ga_len++; default_args->ga_len++;
*p = c; *p = c;
} }
}
else else
mustend = TRUE; mustend = TRUE;
} }
@@ -357,7 +360,7 @@ get_function_args(
err_ret: err_ret:
if (newargs != NULL) if (newargs != NULL)
ga_clear_strings(newargs); ga_clear_strings(newargs);
if (default_args != NULL) if (!skip && default_args != NULL)
ga_clear_strings(default_args); ga_clear_strings(default_args);
return FAIL; return FAIL;
} }

View File

@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3059,
/**/ /**/
3058, 3058,
/**/ /**/