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 9d6df79..adf090b 100644
--- a/src/spellsuggest.c
+++ b/src/spellsuggest.c
@@ -3729,7 +3729,8 @@
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;
}