]> granicus.if.org Git - vim/commitdiff
patch 9.0.0882: using freed memory after SpellFileMissing autocmd uses bwipe v9.0.0882
authorBram Moolenaar <Bram@vim.org>
Mon, 14 Nov 2022 20:52:14 +0000 (20:52 +0000)
committerBram Moolenaar <Bram@vim.org>
Mon, 14 Nov 2022 20:52:14 +0000 (20:52 +0000)
Problem:    Using freed memory after SpellFileMissing autocmd uses bwipe.
Solution:   Bail out if the window no longer exists.

src/spell.c
src/testdir/test_spell.vim
src/version.c

index 508c3ba38b5f8912bea9e3fc128274b3f37f7698..7d8ffe63d8b3fe6f3ff46bcaa73e7faccd95b4fc 100644 (file)
@@ -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;
index 4a7a46c5b39dc63845670cdbfff4986024d9c888..bd387f11d22109be2a066ccf3cb87413849cbd39 100644 (file)
@@ -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.
index c5e78389a5f90e64075904ec127b676f4b9709c9..a35a172acee9090e2c7d9f7fb5a3e77610561f4a 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    882,
 /**/
     881,
 /**/