From: Sami Kerola Date: Fri, 13 Nov 2020 22:58:17 +0000 (+0000) Subject: login: use calloc() when memory needs to be cleared X-Git-Tag: v2.37-rc1~251 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5941a0db06c354d46147d39e16ff122b5bacb4cf;p=thirdparty%2Futil-linux.git login: use calloc() when memory needs to be cleared Signed-off-by: Sami Kerola --- diff --git a/login-utils/login.c b/login-utils/login.c index 4f0296c422..b03808a5c2 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -1159,10 +1159,8 @@ static void init_environ(struct login_context *cxt) termenv = xstrdup(termenv); /* destroy environment unless user has requested preservation (-p) */ - if (!cxt->keep_env) { - environ = xmalloc(sizeof(char *)); - memset(environ, 0, sizeof(char *)); - } + if (!cxt->keep_env) + environ = xcalloc(1, sizeof(char *)); xsetenv("HOME", pwd->pw_dir, 0); /* legal to override */ xsetenv("USER", pwd->pw_name, 1);