]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
Use calloc(3) instead of malloc(3) + memset(3)
authorBaptiste Daroussin <bapt@FreeBSD.org>
Sun, 10 May 2015 11:18:01 +0000 (11:18 +0000)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Sun, 10 May 2015 11:18:01 +0000 (11:18 +0000)
While here check the return of calloc(3)

pw/pw_conf.c

index e988f4bdf12195e07ace1eebbfb4a5641c1b71d2..99d3e8fdbec11105abb4a6f10d687f4569f6a0e3 100644 (file)
@@ -234,8 +234,10 @@ read_userconfig(char const * file)
        buf = NULL;
        linecap = 0;
 
-       extendarray(&config.groups, &config.numgroups, 200);
-       memset(config.groups, 0, config.numgroups * sizeof(char *));
+       config.numgroups = 200;
+       config.groups = calloc(config.numgroups, sizeof(char *));
+       if (config.groups == NULL)
+               err(1, "calloc()");
        if (file == NULL)
                file = _PATH_PW_CONF;