Re: [PATCH 6/9] streaming_write_entry: propagate streaming errors
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Mar 25, 2013, 21:35 UTC
- Message-ID
- <CAPig+cRjK6mrRm+K4Qzf2CsjT3SYGotZ2PrVLniYzdBRC1Mv2A@mail.gmail.com>
- In-Reply-To
- <20130325202216.GF16019@sigill.intra.peff.net>
On Mon, Mar 25, 2013 at 4:22 PM, Jeff King <peff@peff.net> wrote:
Show 14 quoted lines
> diff --git a/entry.c b/entry.c
> index 17a6bcc..002b2f2 100644
> --- a/entry.c
> +++ b/entry.c
> @@ -126,8 +126,10 @@ static int streaming_write_entry(struct cache_entry *ce, char *path,
> fd = open_output_fd(path, ce, to_tempfile);
> if (0 <= fd) {
> result = stream_blob_to_fd(fd, ce->sha1, filter, 1);
> - *fstat_done = fstat_output(fd, state, statbuf);
> - result = close(fd);
> + if (!result) {
> + *fstat_done = fstat_output(fd, state, statbuf);
> + result = close(fd);
> + }Is this intentionally leaking the opened 'fd' when stream_blob_to_fd() returns an error?
> } > if (result && 0 <= fd) > unlink(path);
Won't the unlink() now fail on Windows since 'fd' is still open?
-- ES