1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-25 07:49:18 +00:00

ps(1): Use calloc instead of malloc and memset.

Pull Request:	https://github.com/freebsd/freebsd-src/pull/546
MFC after:	1 week
Sponsored by:	NVIDIA Networking
This commit is contained in:
Alfonso 2021-10-04 12:46:57 -04:00 committed by Hans Petter Selasky
parent c5f549c1e0
commit 3322d1c0e2

View File

@ -1096,8 +1096,7 @@ descendant_sort(KINFO *ki, int items)
* Now populate ki_d.prefix (instead of ki_d.level) with the command
* prefix used to show descendancies.
*/
path = malloc((maxlvl + 7) / 8);
memset(path, '\0', (maxlvl + 7) / 8);
path = calloc((maxlvl + 7) / 8, sizeof(unsigned char));
for (src = 0; src < items; src++) {
if ((lvl = ki[src].ki_d.level) == 0) {
ki[src].ki_d.prefix = NULL;