diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-07-04 13:37:07 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-07-04 13:37:07 +0100 |
commit | 54e5fed6d27b747ff152cdb6edfb72ff60e70939 (patch) | |
tree | 865527f536591729b79b0a0edf3e67dfbcf972df | |
parent | 288ed23e3929ff55a8ae30db0ba3f57b6f119dc8 (diff) | |
download | vim-git-54e5fed6d27b747ff152cdb6edfb72ff60e70939.tar.gz |
patch 9.0.0035: spell dump may go beyond end of an arrayv9.0.0035
Problem: Spell dump may go beyond end of an array.
Solution: Limit the word length.
-rw-r--r-- | src/spell.c | 5 | ||||
-rw-r--r-- | src/testdir/test_spell.vim | 12 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/spell.c b/src/spell.c index d866a2df7..24abce462 100644 --- a/src/spell.c +++ b/src/spell.c @@ -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. diff --git a/src/testdir/test_spell.vim b/src/testdir/test_spell.vim index d3f56d8d1..a291eb5c7 100644 --- a/src/testdir/test_spell.vim +++ b/src/testdir/test_spell.vim @@ -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. diff --git a/src/version.c b/src/version.c index 180a4cf8c..e22fb5673 100644 --- a/src/version.c +++ b/src/version.c @@ -736,6 +736,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 35, +/**/ 34, /**/ 33, |