From e6c64fc1e9b3b9a5ea7101f8a2a499c9e2112da5 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 5 Nov 2005 11:02:56 -0800 Subject: [PATCH] copy.c::copy_fd() - do not leak file descriptor on error return. Signed-off-by: Junio C Hamano --- copy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/copy.c b/copy.c index 20092757d..e1cd5d065 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); -- 2.30.2