Skip to content

Commit

Permalink
patch 8.0.0344: unlet command leaks memory
Browse files Browse the repository at this point in the history
Problem:    Unlet command leaks memory. (Nikolai Pavlov)
Solution:   Free the memory on error. (closes vim#1497)
  • Loading branch information
brammool authored and desvp committed May 30, 2017
1 parent 17291a7 commit 7863577
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/eval.c
Expand Up @@ -2079,7 +2079,10 @@ get_lval(
}
/* existing variable, need to check if it can be changed */
else if (var_check_ro(lp->ll_di->di_flags, name, FALSE))
{
clear_tv(&var1);
return NULL;
}

if (len == -1)
clear_tv(&var1);
Expand Down
4 changes: 4 additions & 0 deletions src/testdir/test_unlet.vim
Expand Up @@ -17,3 +17,7 @@ func Test_not_existing()
unlet! does_not_exist
call assert_fails('unlet does_not_exist', 'E108:')
endfunc

func Test_unlet_fails()
call assert_fails('unlet v:["count"]', 'E46:')
endfunc
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -764,6 +764,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
344,
/**/
343,
/**/
Expand Down

0 comments on commit 7863577

Please sign in to comment.