Module Name: src Committed By: nia Date: Fri Oct 29 10:29:51 UTC 2021
Modified Files: src/lib/libc/stdlib: radixsort.c Log Message: radixsort(3): use reallocarr instead of malloc(x * y) To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/lib/libc/stdlib/radixsort.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/stdlib/radixsort.c diff -u src/lib/libc/stdlib/radixsort.c:1.19 src/lib/libc/stdlib/radixsort.c:1.20 --- src/lib/libc/stdlib/radixsort.c:1.19 Sat Sep 5 08:53:06 2009 +++ src/lib/libc/stdlib/radixsort.c Fri Oct 29 10:29:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: radixsort.c,v 1.19 2009/09/05 08:53:06 dsl Exp $ */ +/* $NetBSD: radixsort.c,v 1.20 2021/10/29 10:29:51 nia Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)radixsort.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: radixsort.c,v 1.19 2009/09/05 08:53:06 dsl Exp $"); +__RCSID("$NetBSD: radixsort.c,v 1.20 2021/10/29 10:29:51 nia Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -129,7 +129,8 @@ sradixsort(const u_char **a, int n, cons if (n < THRESHOLD) simplesort(a, n, 0, tr, endch); else { - if ((ta = malloc(n * sizeof(a))) == NULL) + ta = NULL; + if (reallocarr(&ta, n, sizeof(a)) != 0) return (-1); r_sort_b(a, ta, n, 0, tr, endch); free(ta);