Commit 08337a97 authored by Sam Ravnborg's avatar Sam Ravnborg Committed by Junio C Hamano

copy_fd: close ifd on error

In copy_fd when write fails we ought to close input file descriptor.
Signed-off-by: default avatarSam Ravnborg <[email protected]>
Signed-off-by: default avatarJunio C Hamano <[email protected]>
parent 975b31dc
...@@ -22,11 +22,14 @@ int copy_fd(int ifd, int ofd) ...@@ -22,11 +22,14 @@ int copy_fd(int ifd, int ofd)
buf += written; buf += written;
len -= written; len -= written;
} }
else if (!written) else if (!written) {
close(ifd);
return error("copy-fd: write returned 0"); return error("copy-fd: write returned 0");
else } else {
close(ifd);
return error("copy-fd: write returned %s", return error("copy-fd: write returned %s",
strerror(errno)); strerror(errno));
}
} }
} }
close(ifd); close(ifd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment