Re: [PATCH 1/3] refs/packed-backend.c: close fd of empty file
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- May 31, 2018, 11:49 UTC
- Message-ID
- <CAMy9T_Hc_C-bbzcKBq9HJ4ufzcNJa5NtFQb1h2Uwpe6QL2XRCA@mail.gmail.com>
- In-Reply-To
- <20180530170302.191176-1-sbeller@google.com>
On Wed, May 30, 2018 at 7:03 PM, Stefan Beller <sbeller@google.com> wrote:
Show 26 quoted lines
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>
> This was an oversight in 01caf20d57a (load_contents(): don't try to mmap an
> empty file, 2018-01-24).
>
> This and the following 2 patches apply on master.
>
> refs/packed-backend.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/refs/packed-backend.c b/refs/packed-backend.c
> index cec3fb9e00f..d447a731da0 100644
> --- a/refs/packed-backend.c
> +++ b/refs/packed-backend.c
> @@ -499,6 +499,7 @@ static int load_contents(struct snapshot *snapshot)
> size = xsize_t(st.st_size);
>
> if (!size) {
> + close(fd);
> return 0;
> } else if (mmap_strategy == MMAP_NONE || size <= SMALL_FILE_SIZE) {
> snapshot->buf = xmalloc(size);
> --
> 2.17.1.1185.g55be947832-goog
>+1.
Thanks, Michael