Skip to content
Permalink
Browse files Browse the repository at this point in the history
patch 9.0.0882: using freed memory after SpellFileMissing autocmd use…
…s bwipe

Problem:    Using freed memory after SpellFileMissing autocmd uses bwipe.
Solution:   Bail out if the window no longer exists.
  • Loading branch information
brammool committed Nov 14, 2022
1 parent 24dc19c commit c3d27ad
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/spell.c
Expand Up @@ -2110,8 +2110,8 @@ did_set_spelllang(win_T *wp)
{
spell_load_lang(lang);
// SpellFileMissing autocommands may do anything, including
// destroying the buffer we are using...
if (!bufref_valid(&bufref))
// destroying the buffer we are using or closing the window.
if (!bufref_valid(&bufref) || !win_valid_any_tab(wp))
{
ret_msg = N_(e_spellfilemising_autocommand_deleted_buffer);
goto theend;
Expand Down
13 changes: 13 additions & 0 deletions src/testdir/test_spell.vim
Expand Up @@ -159,6 +159,19 @@ func Test_spell_file_missing()
%bwipe!
endfunc

func Test_spell_file_missing_bwipe()
" this was using a window that was wiped out in a SpellFileMissing autocmd
set spelllang=xy
au SpellFileMissing * n0
set spell
au SpellFileMissing * bw
snext somefile

au! SpellFileMissing
bwipe!
set nospell spelllang=en
endfunc

func Test_spelldump()
" In case the spell file is not found avoid getting the download dialog, we
" would get stuck at the prompt.
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
882,
/**/
881,
/**/
Expand Down

0 comments on commit c3d27ad

Please sign in to comment.