The branch main has been updated by hselasky:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3322d1c0e25448563497acaa5c2358fe465765b8

commit 3322d1c0e25448563497acaa5c2358fe465765b8
Author:     Alfonso <[email protected]>
AuthorDate: 2021-10-04 16:46:57 +0000
Commit:     Hans Petter Selasky <[email protected]>
CommitDate: 2022-03-11 09:36:00 +0000

    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
---
 bin/ps/ps.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index 0c656d8a1544..89d90b78f2b0 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -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;

Reply via email to