Skip to content

Commit

Permalink
patch 8.2.5123: using invalid index when looking for spell suggestions
Browse files Browse the repository at this point in the history
Problem:    Using invalid index when looking for spell suggestions.
Solution:   Do not decrement the index when it is zero.
  • Loading branch information
brammool committed Jun 18, 2022
1 parent 0e8e938 commit 156d391
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/spellsuggest.c
Expand Up @@ -1973,7 +1973,8 @@ suggest_trie_walk(
sp->ts_isdiff = (newscore != 0)
? DIFF_YES : DIFF_NONE;
}
else if (sp->ts_isdiff == DIFF_INSERT)
else if (sp->ts_isdiff == DIFF_INSERT
&& sp->ts_fidx > 0)
// When inserting trail bytes don't advance in the
// bad word.
--sp->ts_fidx;
Expand Down
10 changes: 10 additions & 0 deletions src/testdir/test_spell.vim
Expand Up @@ -70,6 +70,16 @@ func Test_z_equal_on_invalid_utf8_word()
bwipe!
endfunc

func Test_z_equal_on_single_character()
" this was decrementing the index below zero
new
norm a0
norm zW
norm z=

bwipe!
endfunc

" Test spellbadword() with argument
func Test_spellbadword()
set spell
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -734,6 +734,8 @@ static char *(features[]) =

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

0 comments on commit 156d391

Please sign in to comment.