diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2005-12-27 09:19:05 +0100 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-12-27 10:49:25 -0800 |
commit | 08337a97a2756cd89ab611444f37d67250d3c05b (patch) | |
tree | fbcd5fe3b151c0b1412903550b44904b62defb34 | |
parent | 975b31dc6e12fba8f7b067ddbe32230995e05400 (diff) | |
download | git-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.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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); |