Skip to content

Commit 71bcfdf

Browse files
committed
patch 7.4.1068
Problem: Wrong way to check for unletting internal variables. Solution: Use a better way. (Olaf Dabrunz)
1 parent 449538c commit 71bcfdf

2 files changed

Lines changed: 21 additions & 14 deletions

File tree

src/eval.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3738,25 +3738,30 @@ do_unlet(name, forceit)
37383738
ht = find_var_ht(name, &varname);
37393739
if (ht != NULL && *varname != NUL)
37403740
{
3741+
if (ht == &globvarht)
3742+
d = &globvardict;
3743+
else if (current_funccal != NULL
3744+
&& ht == &current_funccal->l_vars.dv_hashtab)
3745+
d = &current_funccal->l_vars;
3746+
else if (ht == &compat_hashtab)
3747+
d = &vimvardict;
3748+
else
3749+
{
3750+
di = find_var_in_ht(ht, *name, (char_u *)"", FALSE);
3751+
d = di == NULL ? NULL : di->di_tv.vval.v_dict;
3752+
}
3753+
if (d == NULL)
3754+
{
3755+
EMSG2(_(e_intern2), "do_unlet()");
3756+
return FAIL;
3757+
}
37413758
hi = hash_find(ht, varname);
37423759
if (!HASHITEM_EMPTY(hi))
37433760
{
37443761
di = HI2DI(hi);
37453762
if (var_check_fixed(di->di_flags, name, FALSE)
3746-
|| var_check_ro(di->di_flags, name, FALSE))
3747-
return FAIL;
3748-
3749-
if (ht == &globvarht)
3750-
d = &globvardict;
3751-
else if (current_funccal != NULL
3752-
&& ht == &current_funccal->l_vars.dv_hashtab)
3753-
d = &current_funccal->l_vars;
3754-
else
3755-
{
3756-
di = find_var_in_ht(ht, *name, (char_u *)"", FALSE);
3757-
d = di->di_tv.vval.v_dict;
3758-
}
3759-
if (d == NULL || tv_check_lock(d->dv_lock, name, FALSE))
3763+
|| var_check_ro(di->di_flags, name, FALSE)
3764+
|| tv_check_lock(d->dv_lock, name, FALSE))
37603765
return FAIL;
37613766

37623767
delete_var(ht, hi);

src/version.c

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

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
1068,
744746
/**/
745747
1067,
746748
/**/

0 commit comments

Comments
 (0)