Skip to content

Commit

Permalink
copy.c::copy_fd() - do not leak file descriptor on error return.
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Nov 5, 2005
1 parent 28ffb89 commit e6c64fc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e6c64fc

Please sign in to comment.