mirror of
https://github.com/neovim/neovim.git
synced 2025-10-03 16:36:30 +00:00
vim-patch:8.2.5007: spell suggestion may use uninitialized memory
Problem: Spell suggestion may use uninitialized memory. (Zdenek Dohnal)
Solution: Avoid going over the end of the word.
6d24b4ff69
This commit is contained in:
@@ -4381,7 +4381,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
#endif
|
#endif
|
||||||
++depth;
|
++depth;
|
||||||
sp = &stack[depth];
|
sp = &stack[depth];
|
||||||
++sp->ts_fidx;
|
if (fword[sp->ts_fidx] != NUL) {
|
||||||
|
sp->ts_fidx++;
|
||||||
|
}
|
||||||
tword[sp->ts_twordlen++] = c;
|
tword[sp->ts_twordlen++] = c;
|
||||||
sp->ts_arridx = idxs[arridx];
|
sp->ts_arridx = idxs[arridx];
|
||||||
if (newscore == SCORE_SUBST) {
|
if (newscore == SCORE_SUBST) {
|
||||||
|
@@ -631,7 +631,7 @@ func Test_spell_affix()
|
|||||||
\ ["bar", "barbork", "end", "fooa1", "fooa\u00E9", "nouend", "prebar", "prebarbork", "start"],
|
\ ["bar", "barbork", "end", "fooa1", "fooa\u00E9", "nouend", "prebar", "prebarbork", "start"],
|
||||||
\ [
|
\ [
|
||||||
\ ["bad", ["bar", "end", "fooa1"]],
|
\ ["bad", ["bar", "end", "fooa1"]],
|
||||||
\ ["foo", ["fooa1", "fooa\u00E9", "bar"]],
|
\ ["foo", ["fooa1", "bar", "end"]],
|
||||||
\ ["fooa2", ["fooa1", "fooa\u00E9", "bar"]],
|
\ ["fooa2", ["fooa1", "fooa\u00E9", "bar"]],
|
||||||
\ ["prabar", ["prebar", "bar", "bar bar"]],
|
\ ["prabar", ["prebar", "bar", "bar bar"]],
|
||||||
\ ["probarbirk", ["prebarbork"]],
|
\ ["probarbirk", ["prebarbork"]],
|
||||||
@@ -649,7 +649,7 @@ func Test_spell_affix()
|
|||||||
\ ["bar", "barbork", "end", "lead", "meea1", "meea\u00E9", "prebar", "prebarbork"],
|
\ ["bar", "barbork", "end", "lead", "meea1", "meea\u00E9", "prebar", "prebarbork"],
|
||||||
\ [
|
\ [
|
||||||
\ ["bad", ["bar", "end", "lead"]],
|
\ ["bad", ["bar", "end", "lead"]],
|
||||||
\ ["mee", ["meea1", "meea\u00E9", "bar"]],
|
\ ["mee", ["meea1", "bar", "end"]],
|
||||||
\ ["meea2", ["meea1", "meea\u00E9", "lead"]],
|
\ ["meea2", ["meea1", "meea\u00E9", "lead"]],
|
||||||
\ ["prabar", ["prebar", "bar", "leadbar"]],
|
\ ["prabar", ["prebar", "bar", "leadbar"]],
|
||||||
\ ["probarbirk", ["prebarbork"]],
|
\ ["probarbirk", ["prebarbork"]],
|
||||||
@@ -666,7 +666,7 @@ func Test_spell_affix()
|
|||||||
\ ["bar", "barmeat", "lead", "meea1", "meea\u00E9", "meezero", "prebar", "prebarmeat", "tail"],
|
\ ["bar", "barmeat", "lead", "meea1", "meea\u00E9", "meezero", "prebar", "prebarmeat", "tail"],
|
||||||
\ [
|
\ [
|
||||||
\ ["bad", ["bar", "lead", "tail"]],
|
\ ["bad", ["bar", "lead", "tail"]],
|
||||||
\ ["mee", ["meea1", "meea\u00E9", "bar"]],
|
\ ["mee", ["meea1", "bar", "lead"]],
|
||||||
\ ["meea2", ["meea1", "meea\u00E9", "lead"]],
|
\ ["meea2", ["meea1", "meea\u00E9", "lead"]],
|
||||||
\ ["prabar", ["prebar", "bar", "leadbar"]],
|
\ ["prabar", ["prebar", "bar", "leadbar"]],
|
||||||
\ ["probarmaat", ["prebarmeat"]],
|
\ ["probarmaat", ["prebarmeat"]],
|
||||||
@@ -761,11 +761,15 @@ func Test_spell_sal_and_addition()
|
|||||||
set spl=Xtest_ca.utf-8.spl
|
set spl=Xtest_ca.utf-8.spl
|
||||||
call assert_equal("elequint", FirstSpellWord())
|
call assert_equal("elequint", FirstSpellWord())
|
||||||
call assert_equal("elekwint", SecondSpellWord())
|
call assert_equal("elekwint", SecondSpellWord())
|
||||||
|
|
||||||
|
set spellfile=
|
||||||
|
set spl&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_spellfile_value()
|
func Test_spellfile_value()
|
||||||
set spellfile=Xdir/Xtest.utf-8.add
|
set spellfile=Xdir/Xtest.utf-8.add
|
||||||
set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
|
set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
|
||||||
|
set spellfile=
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_no_crash_with_weird_text()
|
func Test_no_crash_with_weird_text()
|
||||||
@@ -788,5 +792,18 @@ func Test_check_for_valid_word()
|
|||||||
call assert_fails("spellgood! 0\xac", 'E1280:')
|
call assert_fails("spellgood! 0\xac", 'E1280:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" This was going over the end of the word
|
||||||
|
func Test_word_index()
|
||||||
|
new
|
||||||
|
norm R0
|
||||||
|
spellgood! fl0
|
||||||
|
sil norm z=
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
" clear the word list
|
||||||
|
set enc=utf-8
|
||||||
|
call delete('Xtmpfile')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user