vim-patch:9.0.0035: spell dump may go beyond end of an array (#19228)

Problem:    Spell dump may go beyond end of an array.
Solution:   Limit the word length.
54e5fed6d2
This commit is contained in:
zeertzjq
2022-07-05 06:47:58 +08:00
committed by GitHub
parent 826fe56f5c
commit d07a39c54b
2 changed files with 15 additions and 2 deletions

View File

@@ -7023,8 +7023,9 @@ void spell_dump_compl(char_u *pat, int ic, Direction *dir, int dumpflags_arg)
n = arridx[depth] + curi[depth]; n = arridx[depth] + curi[depth];
++curi[depth]; ++curi[depth];
c = byts[n]; 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, // Don't use keep-case words in the fold-case tree,
// they will appear in the keep-case tree. // they will appear in the keep-case tree.
// Only use the word when the region matches. // Only use the word when the region matches.

View File

@@ -287,6 +287,18 @@ func Test_spellreall()
bwipe! bwipe!
endfunc 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}]]) " Test spellsuggest({word} [, {max} [, {capital}]])
func Test_spellsuggest() func Test_spellsuggest()
" Verify suggestions are given even when spell checking is not enabled. " Verify suggestions are given even when spell checking is not enabled.