NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/46818: Replace malloc with calloc in fts.c



>Number:         46818
>Category:       lib
>Synopsis:       Replace malloc with calloc in fts.c
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 20 11:45:00 +0000 2012
>Originator:     Henning Petersen
>Release:        NetBSD-current
>Organization:
>Environment:
>Description:
Replace malloc and memset with calloc.
>How-To-Repeat:

>Fix:
diff -u -p -r1.44 fts.c
--- lib/libc/gen/fts.c  14 Mar 2012 00:25:19 -0000      1.44
+++ lib/libc/gen/fts.c  2 Aug 2012 15:45:07 -0000
@@ -133,9 +133,8 @@ fts_open(char * const *argv, int options
        }
 
        /* Allocate/initialize the stream */
-       if ((sp = malloc((unsigned int)sizeof(FTS))) == NULL)
+       if ((sp = calloc(1, sizeof(FTS))) == NULL)
                return (NULL);
-       memset(sp, 0, sizeof(FTS));
        sp->fts_compar = compar;
        sp->fts_options = options;



Home | Main Index | Thread Index | Old Index