diff options
author | Junio C Hamano <junkio@cox.net> | 2005-11-05 11:02:56 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-11-05 11:02:56 -0800 |
commit | e6c64fc1e9b3b9a5ea7101f8a2a499c9e2112da5 (patch) | |
tree | 13db03ab4c21816447ba0f9ea9fe339e29cb7887 | |
parent | 28ffb8987af97e28accc707c724207fbd745b027 (diff) | |
download | git-e6c64fc1e9b3b9a5ea7101f8a2a499c9e2112da5.tar.gz git-e6c64fc1e9b3b9a5ea7101f8a2a499c9e2112da5.tar.xz |
copy.c::copy_fd() - do not leak file descriptor on error return.
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r-- | copy.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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); |