Mercurial > vim
changeset 18957:305a7a8d9d4b v8.2.0039
patch 8.2.0039: memory access error when "z=" has no suggestions
Commit: https://github.com/vim/vim/commit/569fea2c312126dd5a542c4b1aa51095136a2c0d
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Dec 25 13:55:24 2019 +0100
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 25 Dec 2019 14:00:04 +0100 |
parents | 5d4ff09e5a11 |
children | 7fa5bc853e56 |
files | src/spellsuggest.c src/testdir/test_spell.vim src/version.c |
diffstat | 3 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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; }
--- a/src/testdir/test_spell.vim +++ b/src/testdir/test_spell.vim @@ -241,9 +241,7 @@ func Test_spellsuggest_option_number() \ .. "Type number and <Enter> 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.