From: Junio C Hamano Date: Sat, 5 Nov 2005 19:02:56 +0000 (-0800) Subject: copy.c::copy_fd() - do not leak file descriptor on error return. X-Git-Tag: v0.99.9d^2~2 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=e6c64fc1e9b3b9a5ea7101f8a2a499c9e2112da5;p=git.git copy.c::copy_fd() - do not leak file descriptor on error return. Signed-off-by: Junio C Hamano --- diff --git a/copy.c b/copy.c index 20092757..e1cd5d06 100644 --- a/copy.c +++ b/copy.c @@ -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);