From 747168d4441ccff1b222b72d8b7478215d76d8fd Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 20 Feb 2013 21:31:09 +0000 Subject: [PATCH] login: remove file descriptor leak [cppcheck] [login-utils/login.c:510]: (error) Resource leak: fd Signed-off-by: Sami Kerola --- login-utils/login.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/login-utils/login.c b/login-utils/login.c index a17083b5f8..425053406a 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -506,8 +506,10 @@ static void log_lastlog(struct login_context *cxt) if (fd < 0) return; - if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1) + if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1) { + close(fd); return; + } /* * Print last log message -- 2.47.3