Browse Source

copy_fd: close ifd on error

In copy_fd when write fails we ought to close input file descriptor.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Sam Ravnborg 19 years ago committed by Junio C Hamano
parent
commit
08337a97a2
  1. 7
      copy.c

7
copy.c

@ -22,11 +22,14 @@ int copy_fd(int ifd, int ofd) @@ -22,11 +22,14 @@ int copy_fd(int ifd, int ofd)
buf += written;
len -= written;
}
else if (!written)
else if (!written) {
close(ifd);
return error("copy-fd: write returned 0");
else
} else {
close(ifd);
return error("copy-fd: write returned %s",
strerror(errno));
}
}
}
close(ifd);

Loading…
Cancel
Save