]> granicus.if.org Git - vim/commitdiff
patch 8.2.1770: invalid memory use when using SpellFileMissing autocmd v8.2.1770
authorBram Moolenaar <Bram@vim.org>
Mon, 28 Sep 2020 21:13:15 +0000 (23:13 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 28 Sep 2020 21:13:15 +0000 (23:13 +0200)
Problem:    Invalid memory use when using SpellFileMissing autocmd.
Solution:   Add test case. (Dominique PellĂ©, closes #7036)  Fix using a window
            that was closed.

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

index 6b431fa5bfa694810f5600034dae788d7515ccf8..085f3177cb7aff78aeb6ff6393a636d2c3f33b8a 100644 (file)
@@ -2280,11 +2280,11 @@ did_set_spelllang(win_T *wp)
                }
            }
     }
+    redraw_win_later(wp, NOT_VALID);
 
 theend:
     vim_free(spl_copy);
     recursive = FALSE;
-    redraw_win_later(wp, NOT_VALID);
     return ret_msg;
 }
 
index db40cd24a65d7579f1ad44a95c5e004c0cc5a517..dd68e0c0908c4987e4553fadb33339ee6d8b9f4b 100644 (file)
@@ -120,6 +120,29 @@ foobar/?
   set spell&
 endfunc
 
+func Test_spell_file_missing()
+  let s:spell_file_missing = 0
+  augroup TestSpellFileMissing
+    autocmd! SpellFileMissing * let s:spell_file_missing += 1
+  augroup END
+
+  set spell spelllang=ab_cd
+  let messages = GetMessages()
+  call assert_equal('Warning: Cannot find word list "ab.utf-8.spl" or "ab.ascii.spl"', messages[-1])
+  call assert_equal(1, s:spell_file_missing)
+
+  new XTestSpellFileMissing
+  augroup TestSpellFileMissing
+    autocmd! SpellFileMissing * bwipe
+  augroup END
+  call assert_fails('set spell spelllang=ab_cd', 'E797:')
+
+  augroup! TestSpellFileMissing
+  unlet s:spell_file_missing
+  set spell& spelllang&
+  %bwipe!
+endfunc
+
 func Test_spelllang_inv_region()
   set spell spelllang=en_xx
   let messages = GetMessages()
index 3d37c85bcf67f6e04a354220def0eeba834ad60c..26e63c2bd23a67739f7b2606b9ebe4a25ece51ac 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1770,
 /**/
     1769,
 /**/