Skip to content

Commit 54e5fed

Browse files
committed
patch 9.0.0035: spell dump may go beyond end of an array
Problem: Spell dump may go beyond end of an array. Solution: Limit the word length.
1 parent 288ed23 commit 54e5fed

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/spell.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3996,9 +3996,10 @@ spell_dump_compl(
39963996
n = arridx[depth] + curi[depth];
39973997
++curi[depth];
39983998
c = byts[n];
3999-
if (c == 0)
3999+
if (c == 0 || depth >= MAXWLEN - 1)
40004000
{
4001-
// End of word, deal with the word.
4001+
// End of word or reached maximum length, deal with the
4002+
// word.
40024003
// Don't use keep-case words in the fold-case tree,
40034004
// they will appear in the keep-case tree.
40044005
// Only use the word when the region matches.

src/testdir/test_spell.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,18 @@ func Test_spellreall()
285285
bwipe!
286286
endfunc
287287

288+
func Test_spell_dump_word_length()
289+
" this was running over MAXWLEN
290+
new
291+
noremap 0 0a0zW0000000
292+
sil! norm 0z=0
293+
sil norm 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
294+
sil! norm 0z=0
295+
296+
bwipe!
297+
nunmap 0
298+
endfunc
299+
288300
" Test spellsuggest({word} [, {max} [, {capital}]])
289301
func Test_spellsuggest()
290302
" Verify suggestions are given even when spell checking is not enabled.

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,8 @@ static char *(features[]) =
735735

736736
static int included_patches[] =
737737
{ /* Add new patch number below this line */
738+
/**/
739+
35,
738740
/**/
739741
34,
740742
/**/

0 commit comments

Comments
 (0)