patch 8.2.1564: a few remaining errors from ubsan
Problem: A few remaining errors from ubsan.
Solution: Avoid the warnings. (Dominique Pellé, closes #6837)
diff --git a/src/spellsuggest.c b/src/spellsuggest.c
index 96e7bb6..e2423cd 100644
--- a/src/spellsuggest.c
+++ b/src/spellsuggest.c
@@ -3731,9 +3731,6 @@
int maxscore,
int keep) // nr of suggestions to keep
{
- suggest_T *stp = &SUG(*gap, 0);
- int i;
-
if (gap->ga_len > 0)
{
// Sort the list.
@@ -3744,6 +3741,9 @@
// displayed.
if (gap->ga_len > keep)
{
+ int i;
+ suggest_T *stp = &SUG(*gap, 0);
+
for (i = keep; i < gap->ga_len; ++i)
vim_free(stp[i].st_word);
gap->ga_len = keep;