From 9d33f7c22fda81f7be8a7aa1576e6d399d3b45ec Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Thu, 16 Jul 2009 16:25:18 -0500 Subject: [PATCH] refs.c: release file descriptor on error return Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- refs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/refs.c b/refs.c index 90163bdc5..bb0762ee2 100644 --- a/refs.c +++ b/refs.c @@ -1525,8 +1525,10 @@ int for_each_recent_reflog_ent(const char *ref, each_reflog_ent_fn fn, long ofs, if (fstat(fileno(logfp), &statbuf) || statbuf.st_size < ofs || fseek(logfp, -ofs, SEEK_END) || - fgets(buf, sizeof(buf), logfp)) + fgets(buf, sizeof(buf), logfp)) { + fclose(logfp); return -1; + } } while (fgets(buf, sizeof(buf), logfp)) { -- 2.26.2