Skip to content

Commit 9d33f7c

Browse files
drafnelgitster
authored andcommitted
refs.c: release file descriptor on error return
Signed-off-by: Brandon Casey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 49902bd commit 9d33f7c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

refs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,8 +1525,10 @@ int for_each_recent_reflog_ent(const char *ref, each_reflog_ent_fn fn, long ofs,
15251525
if (fstat(fileno(logfp), &statbuf) ||
15261526
statbuf.st_size < ofs ||
15271527
fseek(logfp, -ofs, SEEK_END) ||
1528-
fgets(buf, sizeof(buf), logfp))
1528+
fgets(buf, sizeof(buf), logfp)) {
1529+
fclose(logfp);
15291530
return -1;
1531+
}
15301532
}
15311533

15321534
while (fgets(buf, sizeof(buf), logfp)) {

0 commit comments

Comments
 (0)