mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
vim-patch:8.2.0387: error for possible NULL argument to qsort()
Problem: Error for possible NULL argument to qsort().
Solution: Don't call qsort() when there is nothing to sort. (Dominique
Pelle, closes vim/vim#5780)
bb65a5690c
This commit is contained in:
@@ -5761,19 +5761,22 @@ cleanup_suggestions (
|
|||||||
int maxscore,
|
int maxscore,
|
||||||
int keep // nr of suggestions to keep
|
int keep // nr of suggestions to keep
|
||||||
)
|
)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
suggest_T *stp = &SUG(*gap, 0);
|
suggest_T *stp = &SUG(*gap, 0);
|
||||||
|
|
||||||
// Sort the list.
|
if (gap->ga_len > 0) {
|
||||||
qsort(gap->ga_data, (size_t)gap->ga_len, sizeof(suggest_T), sug_compare);
|
// Sort the list.
|
||||||
|
qsort(gap->ga_data, (size_t)gap->ga_len, sizeof(suggest_T), sug_compare);
|
||||||
|
|
||||||
// Truncate the list to the number of suggestions that will be displayed.
|
// Truncate the list to the number of suggestions that will be displayed.
|
||||||
if (gap->ga_len > keep) {
|
if (gap->ga_len > keep) {
|
||||||
for (int i = keep; i < gap->ga_len; ++i) {
|
for (int i = keep; i < gap->ga_len; i++) {
|
||||||
xfree(stp[i].st_word);
|
xfree(stp[i].st_word);
|
||||||
|
}
|
||||||
|
gap->ga_len = keep;
|
||||||
|
return stp[keep - 1].st_score;
|
||||||
}
|
}
|
||||||
gap->ga_len = keep;
|
|
||||||
return stp[keep - 1].st_score;
|
|
||||||
}
|
}
|
||||||
return maxscore;
|
return maxscore;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user