Skip to content

Commit 49439c4

Browse files
committed
patch 8.0.0344: unlet command leaks memory
Problem: Unlet command leaks memory. (Nikolai Pavlov) Solution: Free the memory on error. (closes #1497)
1 parent e7877fe commit 49439c4

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/eval.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,7 +2079,10 @@ get_lval(
20792079
}
20802080
/* existing variable, need to check if it can be changed */
20812081
else if (var_check_ro(lp->ll_di->di_flags, name, FALSE))
2082+
{
2083+
clear_tv(&var1);
20822084
return NULL;
2085+
}
20832086

20842087
if (len == -1)
20852088
clear_tv(&var1);

src/testdir/test_unlet.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ func Test_not_existing()
1717
unlet! does_not_exist
1818
call assert_fails('unlet does_not_exist', 'E108:')
1919
endfunc
20+
21+
func Test_unlet_fails()
22+
call assert_fails('unlet v:["count"]', 'E46:')
23+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
344,
767769
/**/
768770
343,
769771
/**/

0 commit comments

Comments
 (0)