mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
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 #5780)
This commit is contained in:
@@ -3719,17 +3719,22 @@ cleanup_suggestions(
|
|||||||
suggest_T *stp = &SUG(*gap, 0);
|
suggest_T *stp = &SUG(*gap, 0);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// Sort the list.
|
if (gap->ga_len > 0)
|
||||||
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.
|
|
||||||
if (gap->ga_len > keep)
|
|
||||||
{
|
{
|
||||||
for (i = keep; i < gap->ga_len; ++i)
|
// Sort the list.
|
||||||
vim_free(stp[i].st_word);
|
qsort(gap->ga_data, (size_t)gap->ga_len, sizeof(suggest_T),
|
||||||
gap->ga_len = keep;
|
sug_compare);
|
||||||
if (keep >= 1)
|
|
||||||
return stp[keep - 1].st_score;
|
// Truncate the list to the number of suggestions that will be
|
||||||
|
// displayed.
|
||||||
|
if (gap->ga_len > keep)
|
||||||
|
{
|
||||||
|
for (i = keep; i < gap->ga_len; ++i)
|
||||||
|
vim_free(stp[i].st_word);
|
||||||
|
gap->ga_len = keep;
|
||||||
|
if (keep >= 1)
|
||||||
|
return stp[keep - 1].st_score;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return maxscore;
|
return maxscore;
|
||||||
}
|
}
|
||||||
|
@@ -738,6 +738,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
387,
|
||||||
/**/
|
/**/
|
||||||
386,
|
386,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user