On Thu, Oct 05, 2017 at 08:19:13PM +0900, Junio C Hamano wrote:

> > diff --git a/entry.c b/entry.c
> > index 1c7e3c11d5..5dab656364 100644
> > --- a/entry.c
> > +++ b/entry.c
> > @@ -304,7 +304,7 @@ static int write_entry(struct cache_entry *ce,
> >                                     ce->name, new, size, &buf, dco);
> >                             if (ret && string_list_has_string(&dco->paths, 
> > ce->name)) {
> >                                     free(new);
> > -                                   goto finish;
> > +                                   goto delayed;
> >                             }
> >                     } else
> >                             ret = convert_to_working_tree(
> 
> This is unrelated to the main topic of this patch, but we see this
> just before the precontext of this hunk:
> 
>                       if (dco && dco->state != CE_NO_DELAY) {
>                               /* Do not send the blob in case of a retry. */
>                               if (dco->state == CE_RETRY) {
>                                       new = NULL;
>                                       size = 0;
>                               }
>                               ret = async_convert_to_working_tree(
>                                       ce->name, new, size, &buf, dco);
> 
> Aren't we leaking "new" in that CE_RETRY case?

Yes, it certainly looks like it. Wouldn't we want to avoid reading the
file from disk entirely in that case?

I.e., I think free(new) is sufficient to fix the leak you mentioned. But
I think we'd want to protect the read_blob_entry() call at the top of
the case with a check for dco->state == CE_RETRY.

-Peff

Reply via email to