0
0
mirror of https://github.com/vim/vim.git synced 2025-10-12 06:44:06 -04:00

patch 8.2.0039: memory access error when "z=" has no suggestions

Problem:    Memory access error when "z=" has no suggestions.
Solution:   Check for negative index.
This commit is contained in:
Bram Moolenaar
2019-12-25 13:55:24 +01:00
parent e9a8d1f9ad
commit 569fea2c31
3 changed files with 5 additions and 4 deletions

View File

@@ -3729,6 +3729,7 @@ cleanup_suggestions(
for (i = keep; i < gap->ga_len; ++i) for (i = keep; i < gap->ga_len; ++i)
vim_free(stp[i].st_word); vim_free(stp[i].st_word);
gap->ga_len = keep; gap->ga_len = keep;
if (keep >= 1)
return stp[keep - 1].st_score; return stp[keep - 1].st_score;
} }
return maxscore; return maxscore;

View File

@@ -241,9 +241,7 @@ func Test_spellsuggest_option_number()
\ .. "Type number and <Enter> or click with mouse (empty cancels): ", a) \ .. "Type number and <Enter> or click with mouse (empty cancels): ", a)
set spell spellsuggest=0 set spell spellsuggest=0
" FIXME: the following line is currently commented out as it triggers a call assert_equal("\nSorry, no suggestions", execute('norm z='))
" memory error detected in cleanup_suggestions() by asan or valgrind.
"call assert_equal("\nSorry, no suggestions", execute('norm z='))
" Unlike z=, function spellsuggest(...) should not be affected by the " Unlike z=, function spellsuggest(...) should not be affected by the
" max number of suggestions (2) set by the 'spellsuggest' option. " max number of suggestions (2) set by the 'spellsuggest' option.

View File

@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
39,
/**/ /**/
38, 38,
/**/ /**/