summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2005-12-27 09:19:05 +0100
committerJunio C Hamano <junkio@cox.net>2005-12-27 10:49:25 -0800
commit08337a97a2756cd89ab611444f37d67250d3c05b (patch)
treefbcd5fe3b151c0b1412903550b44904b62defb34
parent975b31dc6e12fba8f7b067ddbe32230995e05400 (diff)
downloadgit-08337a97a2756cd89ab611444f37d67250d3c05b.tar.gz
copy_fd: close ifd on error
In copy_fd when write fails we ought to close input file descriptor. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--copy.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/copy.c b/copy.c
index 7100eedbc3..08a3d388a4 100644
--- a/copy.c
+++ b/copy.c
@@ -22,11 +22,14 @@ int copy_fd(int ifd, int ofd)
buf += written;
len -= written;
}
- else if (!written)
+ else if (!written) {
+ close(ifd);
return error("copy-fd: write returned 0");
- else
+ } else {
+ close(ifd);
return error("copy-fd: write returned %s",
strerror(errno));
+ }
}
}
close(ifd);