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,13 +22,16 @@ 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);
return 0;
}
......
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