Skip to content

Commit 7f8508e

Browse files
Linus TorvaldsJunio C Hamano
authored andcommitted
Fix double "close()" in ce_compare_data
Doing an "strace" on "git diff" shows that we close() a file descriptor twice (getting EBADFD on the second one) when we end up in ce_compare_data if the index does not match the checked-out stat information. The "index_fd()" function will already have closed the fd for us, so we should not close it again. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent b63fafd commit 7f8508e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

read-cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static int ce_compare_data(struct cache_entry *ce, struct stat *st)
6161
unsigned char sha1[20];
6262
if (!index_fd(sha1, fd, st, 0, NULL))
6363
match = memcmp(sha1, ce->sha1, 20);
64-
close(fd);
64+
/* index_fd() closed the file descriptor already */
6565
}
6666
return match;
6767
}

0 commit comments

Comments
 (0)