refs.c: release file descriptor on error return
authorBrandon Casey <drafnel@gmail.com>
Thu, 16 Jul 2009 21:25:18 +0000 (16:25 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Jul 2009 22:07:24 +0000 (15:07 -0700)
Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c

diff --git a/refs.c b/refs.c
index 90163bdc56868151e4fd45ff77aa3bd56db45573..bb0762ee2bcb736e72db1c0bbda0604246f14c15 100644 (file)
--- 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)) {