mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 7.4.1051
Problem: Segfault when unletting "count". Solution: Check for readonly and locked first. (Dominique Pelle) Add a test.
This commit is contained in:
27
src/eval.c
27
src/eval.c
@@ -3737,24 +3737,27 @@ do_unlet(name, forceit)
|
|||||||
ht = find_var_ht(name, &varname);
|
ht = find_var_ht(name, &varname);
|
||||||
if (ht != NULL && *varname != NUL)
|
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
|
|
||||||
{
|
|
||||||
di = find_var_in_ht(ht, *name, (char_u *)"", FALSE);
|
|
||||||
d = di->di_tv.vval.v_dict;
|
|
||||||
}
|
|
||||||
hi = hash_find(ht, varname);
|
hi = hash_find(ht, varname);
|
||||||
if (!HASHITEM_EMPTY(hi))
|
if (!HASHITEM_EMPTY(hi))
|
||||||
{
|
{
|
||||||
di = HI2DI(hi);
|
di = HI2DI(hi);
|
||||||
if (var_check_fixed(di->di_flags, name, FALSE)
|
if (var_check_fixed(di->di_flags, name, FALSE)
|
||||||
|| var_check_ro(di->di_flags, name, FALSE)
|
|| var_check_ro(di->di_flags, name, FALSE))
|
||||||
|| tv_check_lock(d->dv_lock, name, FALSE))
|
|
||||||
return FAIL;
|
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))
|
||||||
|
return FAIL;
|
||||||
|
|
||||||
delete_var(ht, hi);
|
delete_var(ht, hi);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@@ -8,3 +8,4 @@ source test_searchpos.vim
|
|||||||
source test_set.vim
|
source test_set.vim
|
||||||
source test_sort.vim
|
source test_sort.vim
|
||||||
source test_undolevels.vim
|
source test_undolevels.vim
|
||||||
|
source test_unlet.vim
|
||||||
|
26
src/testdir/test_unlet.vim
Normal file
26
src/testdir/test_unlet.vim
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
" Tests for :unlet
|
||||||
|
|
||||||
|
func Test_read_only()
|
||||||
|
try
|
||||||
|
" this caused a crash
|
||||||
|
unlet count
|
||||||
|
catch
|
||||||
|
call assert_true(v:exception =~ ':E795:')
|
||||||
|
endtry
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_existing()
|
||||||
|
let does_exist = 1
|
||||||
|
call assert_true(exists('does_exist'))
|
||||||
|
unlet does_exist
|
||||||
|
call assert_false(exists('does_exist'))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_not_existing()
|
||||||
|
unlet! does_not_exist
|
||||||
|
try
|
||||||
|
unlet does_not_exist
|
||||||
|
catch
|
||||||
|
call assert_true(v:exception =~ ':E108:')
|
||||||
|
endtry
|
||||||
|
endfunc
|
@@ -741,6 +741,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1051,
|
||||||
/**/
|
/**/
|
||||||
1050,
|
1050,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user