Skip to content

Commit

Permalink
patch 9.0.0240: crash when using ":mkspell" with an empty .dic file
Browse files Browse the repository at this point in the history
Problem:    Crash when using ":mkspell" with an empty .dic file.
Solution:   Check for an empty word tree.
  • Loading branch information
brammool committed Aug 21, 2022
1 parent 8884916 commit 6669de1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/spellfile.c
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions src/testdir/test_spellfile.vim
Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -731,6 +731,8 @@ static char *(features[]) =

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

0 comments on commit 6669de1

Please sign in to comment.