summaryrefslogtreecommitdiff
path: root/copy.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-11-05 19:02:56 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-11-05 19:02:56 (GMT)
commite6c64fc1e9b3b9a5ea7101f8a2a499c9e2112da5 (patch)
tree13db03ab4c21816447ba0f9ea9fe339e29cb7887 /copy.c
parent28ffb8987af97e28accc707c724207fbd745b027 (diff)
downloadgit-e6c64fc1e9b3b9a5ea7101f8a2a499c9e2112da5.zip
git-e6c64fc1e9b3b9a5ea7101f8a2a499c9e2112da5.tar.gz
git-e6c64fc1e9b3b9a5ea7101f8a2a499c9e2112da5.tar.bz2
copy.c::copy_fd() - do not leak file descriptor on error return.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'copy.c')
-rw-r--r--copy.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/copy.c b/copy.c
index 2009275..e1cd5d0 100644
--- a/copy.c
+++ b/copy.c
@@ -10,10 +10,13 @@ int copy_fd(int ifd, int ofd)
if (!len)
break;
if (len < 0) {
+ int read_error;
if (errno == EAGAIN)
continue;
+ read_error = errno;
+ close(ifd);
return error("copy-fd: read returned %s",
- strerror(errno));
+ strerror(read_error));
}
while (1) {
int written = write(ofd, buf, len);