mirror of
https://github.com/mirror/wget.git
synced 2025-02-25 11:20:12 +08:00
* src/utils.c (stable_sort): Reduce tmp allocation size
Reported-by: Coverity
This commit is contained in:
parent
a232835fd1
commit
b4465afa8a
@ -2422,8 +2422,7 @@ mergesort_internal (void *base, void *temp, size_t size, size_t from, size_t to,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Stable sort with interface exactly like standard library's qsort.
|
/* Stable sort with interface exactly like standard library's qsort.
|
||||||
Uses mergesort internally, allocating temporary storage with
|
Uses mergesort internally. */
|
||||||
alloca. */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
stable_sort (void *base, size_t nmemb, size_t size,
|
stable_sort (void *base, size_t nmemb, size_t size,
|
||||||
@ -2431,7 +2430,7 @@ stable_sort (void *base, size_t nmemb, size_t size,
|
|||||||
{
|
{
|
||||||
if (size > 1)
|
if (size > 1)
|
||||||
{
|
{
|
||||||
void *temp = malloc (nmemb * size * sizeof (void *));
|
void *temp = malloc (nmemb * size);
|
||||||
mergesort_internal (base, temp, size, 0, nmemb - 1, cmpfun);
|
mergesort_internal (base, temp, size, 0, nmemb - 1, cmpfun);
|
||||||
xfree(temp);
|
xfree(temp);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user