From: Sam Ravnborg Date: Tue, 27 Dec 2005 08:19:05 +0000 (+0100) Subject: copy_fd: close ifd on error X-Git-Tag: v1.0.6^2~3 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=08337a97a2756cd89ab611444f37d67250d3c05b;p=git.git copy_fd: close ifd on error In copy_fd when write fails we ought to close input file descriptor. Signed-off-by: Sam Ravnborg Signed-off-by: Junio C Hamano --- diff --git a/copy.c b/copy.c index 7100eedb..08a3d388 100644 --- a/copy.c +++ b/copy.c @@ -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);