]> xenbits.xensource.com Git - people/royger/freebsd.git/commitdiff
ps(1): Use calloc instead of malloc and memset.
authorAlfonso <gfunni234@gmail.com>
Mon, 4 Oct 2021 16:46:57 +0000 (12:46 -0400)
committerHans Petter Selasky <hselasky@FreeBSD.org>
Fri, 11 Mar 2022 09:36:00 +0000 (10:36 +0100)
Pull Request: https://github.com/freebsd/freebsd-src/pull/546
MFC after: 1 week
Sponsored by: NVIDIA Networking

bin/ps/ps.c

index 0c656d8a1544180ae5ecbe2e06af8da09f7ddcf4..89d90b78f2b0f02ee8c253873fbc66ef144d81d8 100644 (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;