Skip to content

Commit

Permalink
patch 9.0.0035: spell dump may go beyond end of an array
Browse files Browse the repository at this point in the history
Problem:    Spell dump may go beyond end of an array.
Solution:   Limit the word length.
  • Loading branch information
brammool committed Jul 4, 2022
1 parent 288ed23 commit 54e5fed
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/spell.c
Expand Up @@ -3996,9 +3996,10 @@ spell_dump_compl(
n = arridx[depth] + curi[depth];
++curi[depth];
c = byts[n];
if (c == 0)
if (c == 0 || depth >= MAXWLEN - 1)
{
// End of word, deal with the word.
// End of word or reached maximum length, deal with the
// word.
// Don't use keep-case words in the fold-case tree,
// they will appear in the keep-case tree.
// Only use the word when the region matches.
Expand Down
12 changes: 12 additions & 0 deletions src/testdir/test_spell.vim
Expand Up @@ -285,6 +285,18 @@ func Test_spellreall()
bwipe!
endfunc

func Test_spell_dump_word_length()
" this was running over MAXWLEN
new
noremap 0 0a0zW0000000
sil! norm 0z=0
sil norm 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
sil! norm 0z=0

bwipe!
nunmap 0
endfunc

" Test spellsuggest({word} [, {max} [, {capital}]])
func Test_spellsuggest()
" Verify suggestions are given even when spell checking is not enabled.
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -735,6 +735,8 @@ static char *(features[]) =

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

0 comments on commit 54e5fed

Please sign in to comment.