Mercurial > vim
changeset 7534:0765665083be v7.4.1068
commit https://github.com/vim/vim/commit/71bcfdf30109c3d6e40d143adcaf33964b18a70b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 9 18:20:46 2016 +0100
patch 7.4.1068
Problem: Wrong way to check for unletting internal variables.
Solution: Use a better way. (Olaf Dabrunz)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 09 Jan 2016 18:30:05 +0100 |
parents | 925eda7034aa |
children | 74daa6b68570 |
files | src/eval.c src/version.c |
diffstat | 2 files changed, 21 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -3738,25 +3738,30 @@ do_unlet(name, forceit) ht = find_var_ht(name, &varname); if (ht != NULL && *varname != NUL) { + if (ht == &globvarht) + d = &globvardict; + else if (current_funccal != NULL + && ht == ¤t_funccal->l_vars.dv_hashtab) + d = ¤t_funccal->l_vars; + else if (ht == &compat_hashtab) + d = &vimvardict; + else + { + di = find_var_in_ht(ht, *name, (char_u *)"", FALSE); + d = di == NULL ? NULL : di->di_tv.vval.v_dict; + } + if (d == NULL) + { + EMSG2(_(e_intern2), "do_unlet()"); + return FAIL; + } hi = hash_find(ht, varname); if (!HASHITEM_EMPTY(hi)) { di = HI2DI(hi); if (var_check_fixed(di->di_flags, name, FALSE) - || var_check_ro(di->di_flags, name, FALSE)) - return FAIL; - - if (ht == &globvarht) - d = &globvardict; - else if (current_funccal != NULL - && ht == ¤t_funccal->l_vars.dv_hashtab) - d = ¤t_funccal->l_vars; - else - { - di = find_var_in_ht(ht, *name, (char_u *)"", FALSE); - d = di->di_tv.vval.v_dict; - } - if (d == NULL || tv_check_lock(d->dv_lock, name, FALSE)) + || var_check_ro(di->di_flags, name, FALSE) + || tv_check_lock(d->dv_lock, name, FALSE)) return FAIL; delete_var(ht, hi);