Skip to content

Commit 15d9890

Browse files
committed
patch 8.2.3582: reading uninitialized memory when giving spell suggestions
Problem: Reading uninitialized memory when giving spell suggestions. Solution: Check that preword is not empty.
1 parent 0b5b06c commit 15d9890

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/spellsuggest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ suggest_trie_walk(
16191619
// char, e.g., "thes," -> "these".
16201620
p = fword + sp->ts_fidx;
16211621
MB_PTR_BACK(fword, p);
1622-
if (!spell_iswordp(p, curwin))
1622+
if (!spell_iswordp(p, curwin) && *preword != NUL)
16231623
{
16241624
p = preword + STRLEN(preword);
16251625
MB_PTR_BACK(preword, p);

src/testdir/test_spell.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,14 @@ func Test_spell_screendump()
839839
call delete('XtestSpell')
840840
endfunc
841841

842+
func Test_spell_single_word()
843+
new
844+
silent! norm 0R00
845+
spell! ßÂ
846+
silent 0norm 0r$ Dvz=
847+
bwipe!
848+
endfunc
849+
842850
let g:test_data_aff1 = [
843851
\"SET ISO8859-1",
844852
\"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",

src/version.c

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

758758
static int included_patches[] =
759759
{ /* Add new patch number below this line */
760+
/**/
761+
3582,
760762
/**/
761763
3581,
762764
/**/

0 commit comments

Comments
 (0)