Fix Coverity run 5, issue 2022 -- memory leak.

Approved by christos@.
This commit is contained in:
jnemeth 2006-03-18 10:53:17 +00:00
parent ccd53bd92b
commit 216a33af30

View File

@ -1,4 +1,4 @@
/* $NetBSD: pam_lastlog.c,v 1.9 2006/02/19 00:13:09 christos Exp $ */
/* $NetBSD: pam_lastlog.c,v 1.10 2006/03/18 10:53:17 jnemeth Exp $ */
/*-
* Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
@ -47,7 +47,7 @@
#ifdef __FreeBSD__
__FBSDID("$FreeBSD: src/lib/libpam/modules/pam_lastlog/pam_lastlog.c,v 1.20 2004/01/26 19:28:37 des Exp $");
#else
__RCSID("$NetBSD: pam_lastlog.c,v 1.9 2006/02/19 00:13:09 christos Exp $");
__RCSID("$NetBSD: pam_lastlog.c,v 1.10 2006/03/18 10:53:17 jnemeth Exp $");
#endif
#include <sys/param.h>
@ -104,6 +104,9 @@ pam_sm_open_session(pam_handle_t *pamh, int flags,
const struct sockaddr_storage *ss;
int pam_err;
char pwbuf[1024];
#ifdef LOGIN_CAP
login_cap_t *lc;
#endif
pam_err = pam_get_user(pamh, &user, NULL);
if (pam_err != PAM_SUCCESS)
@ -157,8 +160,9 @@ pam_sm_open_session(pam_handle_t *pamh, int flags,
quiet = 1;
else {
#ifdef LOGIN_CAP
quiet = login_getcapbool(login_getpwclass(pwd),
"hushlogin", 0);
lc = login_getpwclass(pwd);
quiet = login_getcapbool(lc, "hushlogin", 0);
login_close(lc);
#else
quiet = 0;
#endif