diff src/spellsuggest.c @ 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 9e6d5a4abb1c
children 34aa888bf5ad
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;
 }