login_getclassbyname(3): use calloc.

This commit is contained in:
Xin LI 2023-07-23 11:18:24 -07:00
parent 176d83eafc
commit 9df529b8a1

View file

@ -295,7 +295,7 @@ login_getclassbyname(char const *name, const struct passwd *pwd)
{
login_cap_t *lc;
if ((lc = malloc(sizeof(login_cap_t))) != NULL) {
if ((lc = calloc(1, sizeof(login_cap_t))) != NULL) {
int r, me, i = 0;
uid_t euid = 0;
gid_t egid = 0;
@ -332,9 +332,6 @@ login_getclassbyname(char const *name, const struct passwd *pwd)
login_dbarray[i++] = path_login_conf;
login_dbarray[i] = NULL;
memset(lc, 0, sizeof(login_cap_t));
lc->lc_cap = lc->lc_class = lc->lc_style = NULL;
if (name == NULL || *name == '\0')
name = LOGIN_DEFCLASS;