]> granicus.if.org Git - vim/commitdiff
patch 9.0.0240: crash when using ":mkspell" with an empty .dic file v9.0.0240
authorBram Moolenaar <Bram@vim.org>
Sun, 21 Aug 2022 19:33:47 +0000 (20:33 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 21 Aug 2022 19:33:47 +0000 (20:33 +0100)
Problem:    Crash when using ":mkspell" with an empty .dic file.
Solution:   Check for an empty word tree.

src/spellfile.c
src/testdir/test_spellfile.vim
src/version.c

index 5962a1048f6fbe8915f63cbf6a8d6d589ee1a3ef..7620affee8e9ce0444c8cfec5fd535f38336e2c8 100644 (file)
@@ -5585,10 +5585,12 @@ sug_filltree(spellinfo_T *spin, slang_T *slang)
 
     /*
      * Go through the whole case-folded tree, soundfold each word and put it
-     * in the trie.
+     * in the trie.  Bail out if the tree is empty.
      */
     byts = slang->sl_fbyts;
     idxs = slang->sl_fidxs;
+    if (byts == NULL || idxs == NULL)
+       return FAIL;
 
     arridx[0] = 0;
     curi[0] = 1;
index 43dfad4628b67560a3dc5d85f6dca02e5b44cb2a..28e69bdc5da66ad00d34bf32ccad70853682fd8b 100644 (file)
@@ -1168,4 +1168,16 @@ def Test_spellfile_allow_at_character()
   delete('Xtest', 'rf')
 enddef
 
+" this was using a NULL pointer
+func Test_mkspell_empty_dic()
+  call writefile(['1'], 'XtestEmpty.dic')
+  call writefile(['SOFOFROM abcd', 'SOFOTO ABCD', 'SAL CIA X'], 'XtestEmpty.aff')
+  mkspell! XtestEmpty.spl XtestEmpty
+
+  call delete('XtestEmpty.dic')
+  call delete('XtestEmpty.aff')
+  call delete('XtestEmpty.spl')
+endfunc
+
+
 " vim: shiftwidth=2 sts=2 expandtab
index fe100c81026c1cf97d635346073a9fb5b72f9354..9e77abceea2cc93c633ee561c5144c4063957a0b 100644 (file)
@@ -731,6 +731,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    240,
 /**/
     239,
 /**/