From c9b35173704bf9aaebcf62d0915543b81e9ee8d3 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 10 May 2015 11:18:01 +0000 Subject: [PATCH] Use calloc(3) instead of malloc(3) + memset(3) While here check the return of calloc(3) --- pw/pw_conf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pw/pw_conf.c b/pw/pw_conf.c index e988f4b..99d3e8f 100644 --- a/pw/pw_conf.c +++ b/pw/pw_conf.c @@ -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; -- 2.47.1