From: Bram Moolenaar Date: Wed, 25 Dec 2019 12:55:24 +0000 (+0100) Subject: patch 8.2.0039: memory access error when "z=" has no suggestions X-Git-Tag: v8.2.0039 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=569fea2c312126dd5a542c4b1aa51095136a2c0d;p=vim 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. --- diff --git a/src/spellsuggest.c b/src/spellsuggest.c index 9d6df7930..adf090bbe 100644 --- a/src/spellsuggest.c +++ b/src/spellsuggest.c @@ -3729,7 +3729,8 @@ cleanup_suggestions( for (i = keep; i < gap->ga_len; ++i) vim_free(stp[i].st_word); gap->ga_len = keep; - return stp[keep - 1].st_score; + if (keep >= 1) + return stp[keep - 1].st_score; } return maxscore; } diff --git a/src/testdir/test_spell.vim b/src/testdir/test_spell.vim index 091276b45..7080c203b 100644 --- a/src/testdir/test_spell.vim +++ b/src/testdir/test_spell.vim @@ -241,9 +241,7 @@ func Test_spellsuggest_option_number() \ .. "Type number and or click with mouse (empty cancels): ", a) set spell spellsuggest=0 - " FIXME: the following line is currently commented out as it triggers a - " memory error detected in cleanup_suggestions() by asan or valgrind. - "call assert_equal("\nSorry, no suggestions", execute('norm z=')) + call assert_equal("\nSorry, no suggestions", execute('norm z=')) " Unlike z=, function spellsuggest(...) should not be affected by the " max number of suggestions (2) set by the 'spellsuggest' option. diff --git a/src/version.c b/src/version.c index e6f0cf0ab..9f7f48a38 100644 --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 39, /**/ 38, /**/