From: Sami Kerola Date: Wed, 20 Feb 2013 21:31:09 +0000 (+0000) Subject: login: remove file descriptor leak [cppcheck] X-Git-Tag: v2.23-rc1~187 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=747168d4441ccff1b222b72d8b7478215d76d8fd;p=thirdparty%2Futil-linux.git login: remove file descriptor leak [cppcheck] [login-utils/login.c:510]: (error) Resource leak: fd Signed-off-by: Sami Kerola --- 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