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

patch 8.2.2703: Vim9: memory leak when failing on locked variable

Problem:    Vim9: memory leak when failing on locked variable.
Solution:   Free the memory.
This commit is contained in:
Bram Moolenaar 2021-04-03 19:32:44 +02:00
parent c17ba791a9
commit 6e50ec2f0a
3 changed files with 10 additions and 1 deletions

View File

@ -1323,6 +1323,7 @@ def Test_var_declaration()
unlet g:var_test
unlet g:var_prefixed
unlet g:other_var
unlet g:globConst
unlet g:FOO
unlet g:FOOS
unlet g:FLIST
@ -1375,7 +1376,7 @@ def Test_var_declaration_fails()
SetGlobalConst()
g:globConst = 234
END
CheckScriptFailure(lines, 'E741: Value is locked: globConst', 1)
CheckScriptFailure(lines, 'E741: Value is locked: g:globConst', 6)
unlet g:globConst
lines =<< trim END

View File

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

View File

@ -1944,7 +1944,10 @@ call_def_function(
{
SOURCING_LNUM = iptr->isn_lnum;
if (var_check_permission(di, name) == FAIL)
{
clear_tv(STACK_TV_BOT(0));
goto on_error;
}
clear_tv(&di->di_tv);
di->di_tv = *STACK_TV_BOT(0);
}
@ -1966,7 +1969,10 @@ call_def_function(
// the value needs to be checked here.
SOURCING_LNUM = iptr->isn_lnum;
if (value_check_lock(sv->sv_tv->v_lock, sv->sv_name, FALSE))
{
clear_tv(STACK_TV_BOT(0));
goto on_error;
}
clear_tv(sv->sv_tv);
*sv->sv_tv = *STACK_TV_BOT(0);