From 7d5a7934dde5e3cd4e80a643d021ef71bcdc17a1 Mon Sep 17 00:00:00 2001 From: nia Date: Fri, 29 Oct 2021 10:29:51 +0000 Subject: radixsort(3): use reallocarr instead of malloc(x * y) --- lib/libc/stdlib/radixsort.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/libc/stdlib') diff --git a/lib/libc/stdlib/radixsort.c b/lib/libc/stdlib/radixsort.c index e8435f5f2e4..db8a7eb3936 100644 --- a/lib/libc/stdlib/radixsort.c +++ b/lib/libc/stdlib/radixsort.c @@ -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, const u_char *tab, u_int endch) 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); -- cgit