Commits

Junio C Hamano  committed e6c64fc

copy.c::copy_fd() - do not leak file descriptor on error return.

Signed-off-by: Junio C Hamano <junkio@cox.net>

  • Participants
  • Parent commits 28ffb89

Comments (0)

Files changed (1)

 		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);