From: Linus Torvalds Date: Mon, 31 Jul 2006 16:55:15 +0000 (-0700) Subject: Fix double "close()" in ce_compare_data X-Git-Tag: v1.4.2-rc3~28 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7f8508e8d320d768a34483682e9f2dc5af1af04b;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/read-cache.c b/read-cache.c index c0b031367..f92cdaace 100644 --- a/read-cache.c +++ b/read-cache.c @@ -61,7 +61,7 @@ static int ce_compare_data(struct cache_entry *ce, struct stat *st) unsigned char sha1[20]; if (!index_fd(sha1, fd, st, 0, NULL)) match = memcmp(sha1, ce->sha1, 20); - close(fd); + /* index_fd() closed the file descriptor already */ } return match; }