From b4465afa8a1050accd7a6aa3f684ad5ea7512151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Thu, 8 Sep 2016 12:34:59 +0200 Subject: [PATCH] * src/utils.c (stable_sort): Reduce tmp allocation size Reported-by: Coverity --- src/utils.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils.c b/src/utils.c index d8b3c828..31983ccf 100644 --- a/src/utils.c +++ b/src/utils.c @@ -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. - Uses mergesort internally, allocating temporary storage with - alloca. */ + Uses mergesort internally. */ void 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) { - void *temp = malloc (nmemb * size * sizeof (void *)); + void *temp = malloc (nmemb * size); mergesort_internal (base, temp, size, 0, nmemb - 1, cmpfun); xfree(temp); }