copy.c::copy_fd() - do not leak file descriptor on error return.
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
28ffb8987a
commit
e6c64fc1e9
5
copy.c
5
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);
|
||||
|
Loading…
Reference in New Issue
Block a user