]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Fix unportable sizeof() usage
authorGuillem Jover <guillem@hadrons.org>
Sun, 7 Feb 2016 01:47:22 +0000 (02:47 +0100)
committerGuillem Jover <guillem@hadrons.org>
Sun, 7 Feb 2016 08:16:47 +0000 (09:16 +0100)
We are calculating the size of the array, and need to pass the size of
each element, not the size of a pointer to an element. Although this
happens to be the same in many cases, this is not a portable assumption.

Warned-by: coverity
src/radixsort.c

index 1473925779de02746fabd7c2cae0b7e64b1ffef9..ad2ae70f28bf617948f619eb71b79a35a91e02c3 100644 (file)
@@ -118,7 +118,7 @@ sradixsort(const u_char **a, int n, const u_char *tab, u_int endch)
        if (n < THRESHOLD)
                simplesort(a, n, 0, tr, endch);
        else {
-               ta = reallocarray(NULL, n, sizeof(a));
+               ta = reallocarray(NULL, n, sizeof(*a));
                if (ta == NULL)
                        return (-1);
                r_sort_b(a, ta, n, 0, tr, endch);