]> granicus.if.org Git - vim/commitdiff
patch 8.2.3582: reading uninitialized memory when giving spell suggestions v8.2.3582
authorBram Moolenaar <Bram@vim.org>
Thu, 4 Nov 2021 15:46:05 +0000 (15:46 +0000)
committerBram Moolenaar <Bram@vim.org>
Thu, 4 Nov 2021 15:46:05 +0000 (15:46 +0000)
Problem:    Reading uninitialized memory when giving spell suggestions.
Solution:   Check that preword is not empty.

src/spellsuggest.c
src/testdir/test_spell.vim
src/version.c

index a6dbc78a46ab9db67d598385d44c489ebbec9ee0..255f94de0af6de53fdfc93628fd8b9b1a0eed6da 100644 (file)
@@ -1619,7 +1619,7 @@ suggest_trie_walk(
                    // char, e.g., "thes," -> "these".
                    p = fword + sp->ts_fidx;
                    MB_PTR_BACK(fword, p);
-                   if (!spell_iswordp(p, curwin))
+                   if (!spell_iswordp(p, curwin) && *preword != NUL)
                    {
                        p = preword + STRLEN(preword);
                        MB_PTR_BACK(preword, p);
index a3a9621cb0fff8a83a21a3282f9a25b629f295a9..b7437fd448011fc33d33aa413f308d42263f569f 100644 (file)
@@ -839,6 +839,14 @@ func Test_spell_screendump()
   call delete('XtestSpell')
 endfunc
 
+func Test_spell_single_word()
+  new
+  silent! norm 0R00
+  spell! ßÂ
+  silent 0norm 0r$ Dvz=
+  bwipe!
+endfunc
+
 let g:test_data_aff1 = [
       \"SET ISO8859-1",
       \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
index 7bb4236361bb198f01d6797d8f8ddb68149919f2..73ba32ef24965042de40cb8d7bcd6304641a7548 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3582,
 /**/
     3581,
 /**/