Skip to content

Commit

Permalink
copy_fd: close ifd on error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sam Ravnborg authored and Junio C Hamano committed Dec 27, 2005
1 parent 975b31d commit 08337a9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 08337a9

Please sign in to comment.