mirror of
https://github.com/neovim/neovim.git
synced 2025-09-25 12:38:33 +00:00
vim-patch:8.2.0097: crash with autocommand and spellfile
Problem: Crash with autocommand and spellfile. (Tim Pope)
Solution: Do not pop exestack when not pushed. (closes vim/vim#5450)
ce6db0273f
This commit is contained in:
@@ -580,6 +580,7 @@ slang_T *spell_load_file(char_u *fname, char_u *lang, slang_T *old_lp, bool sile
|
|||||||
slang_T *lp = NULL;
|
slang_T *lp = NULL;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
int res;
|
int res;
|
||||||
|
bool did_estack_push = false;
|
||||||
|
|
||||||
fd = os_fopen((char *)fname, "r");
|
fd = os_fopen((char *)fname, "r");
|
||||||
if (fd == NULL) {
|
if (fd == NULL) {
|
||||||
@@ -612,6 +613,7 @@ slang_T *spell_load_file(char_u *fname, char_u *lang, slang_T *old_lp, bool sile
|
|||||||
|
|
||||||
// Set sourcing_name, so that error messages mention the file name.
|
// Set sourcing_name, so that error messages mention the file name.
|
||||||
estack_push(ETYPE_SPELL, (char *)fname, 0);
|
estack_push(ETYPE_SPELL, (char *)fname, 0);
|
||||||
|
did_estack_push = true;
|
||||||
|
|
||||||
// <HEADER>: <fileID>
|
// <HEADER>: <fileID>
|
||||||
const int scms_ret = spell_check_magic_string(fd);
|
const int scms_ret = spell_check_magic_string(fd);
|
||||||
@@ -807,7 +809,9 @@ endOK:
|
|||||||
if (fd != NULL) {
|
if (fd != NULL) {
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
}
|
}
|
||||||
|
if (did_estack_push) {
|
||||||
estack_pop();
|
estack_pop();
|
||||||
|
}
|
||||||
|
|
||||||
return lp;
|
return lp;
|
||||||
}
|
}
|
||||||
|
@@ -2614,6 +2614,28 @@ func Test_BufWrite_lockmarks()
|
|||||||
call delete('Xtest2')
|
call delete('Xtest2')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_FileType_spell()
|
||||||
|
if !isdirectory('/tmp')
|
||||||
|
throw "Skipped: requires /tmp directory"
|
||||||
|
endif
|
||||||
|
|
||||||
|
" this was crashing with an invalid free()
|
||||||
|
setglobal spellfile=/tmp/en.utf-8.add
|
||||||
|
augroup crash
|
||||||
|
autocmd!
|
||||||
|
autocmd BufNewFile,BufReadPost crashfile setf somefiletype
|
||||||
|
autocmd BufNewFile,BufReadPost crashfile set ft=anotherfiletype
|
||||||
|
autocmd FileType anotherfiletype setlocal spell
|
||||||
|
augroup END
|
||||||
|
func! NoCrash() abort
|
||||||
|
edit /tmp/crashfile
|
||||||
|
endfunc
|
||||||
|
call NoCrash()
|
||||||
|
|
||||||
|
au! crash
|
||||||
|
setglobal spellfile=
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test closing a window or editing another buffer from a FileChangedRO handler
|
" Test closing a window or editing another buffer from a FileChangedRO handler
|
||||||
" in a readonly buffer
|
" in a readonly buffer
|
||||||
func Test_FileChangedRO_winclose()
|
func Test_FileChangedRO_winclose()
|
||||||
|
Reference in New Issue
Block a user