copy.c::copy_fd() - do not leak file descriptor on error return.

Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Junio C Hamano 2005-11-05 11:02:56 -08:00
parent 28ffb8987a
commit e6c64fc1e9

5
copy.c
View File

@ -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);