mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 15:28:17 +00:00
vim-patch:7.4.1051
Problem: Segfault when unletting "count".
Solution: Check for readonly and locked first. (Dominique Pelle)
Add a test.
af8af8bfac
This commit is contained in:
@@ -2973,6 +2973,14 @@ int do_unlet(char_u *name, int forceit)
|
|||||||
ht = find_var_ht_dict(name, &varname, &dict);
|
ht = find_var_ht_dict(name, &varname, &dict);
|
||||||
|
|
||||||
if (ht != NULL && *varname != NUL) {
|
if (ht != NULL && *varname != NUL) {
|
||||||
|
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) {
|
if (ht == &globvarht) {
|
||||||
d = &globvardict;
|
d = &globvardict;
|
||||||
} else if (current_funccal != NULL
|
} else if (current_funccal != NULL
|
||||||
@@ -2982,15 +2990,10 @@ int do_unlet(char_u *name, int forceit)
|
|||||||
di = find_var_in_ht(ht, *name, (char_u *)"", false);
|
di = find_var_in_ht(ht, *name, (char_u *)"", false);
|
||||||
d = di->di_tv.vval.v_dict;
|
d = di->di_tv.vval.v_dict;
|
||||||
}
|
}
|
||||||
|
if (d == NULL || tv_check_lock(d->dv_lock, name, false)) {
|
||||||
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)
|
|
||||||
|| tv_check_lock(d->dv_lock, name, false)) {
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
typval_T oldtv;
|
typval_T oldtv;
|
||||||
bool watched = is_watched(dict);
|
bool watched = is_watched(dict);
|
||||||
|
|
||||||
|
@@ -39,6 +39,7 @@ NEW_TESTS = \
|
|||||||
test_menu.res \
|
test_menu.res \
|
||||||
test_syntax.res \
|
test_syntax.res \
|
||||||
test_timers.res \
|
test_timers.res \
|
||||||
|
test_unlet.res \
|
||||||
test_viml.res \
|
test_viml.res \
|
||||||
test_alot.res
|
test_alot.res
|
||||||
|
|
||||||
|
26
src/nvim/testdir/test_unlet.vim
Normal file
26
src/nvim/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
|
@@ -642,7 +642,7 @@ static int included_patches[] = {
|
|||||||
1054,
|
1054,
|
||||||
1053,
|
1053,
|
||||||
1052,
|
1052,
|
||||||
// 1051,
|
1051,
|
||||||
1050,
|
1050,
|
||||||
1049,
|
1049,
|
||||||
1048,
|
1048,
|
||||||
|
Reference in New Issue
Block a user