Fix double "close()" in ce_compare_data
authorLinus Torvalds <torvalds@osdl.org>
Mon, 31 Jul 2006 16:55:15 +0000 (09:55 -0700)
committerJunio C Hamano <junkio@cox.net>
Mon, 31 Jul 2006 18:55:56 +0000 (11:55 -0700)
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>
read-cache.c
index c0b031367bf0d33e535cdfc183da2276577c8011..f92cdaacee1b43bf09929e7072c281dbcbb09c10 100644 (file)
@@ -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;
 }