Re: [PATCH] Fix memory leak in transport-helper
- From
Daniel Barkalow <barkalow@iabervon.org>
- Date
- Oct 27, 2009, 19:05 UTC
- Message-ID
- <alpine.LNX.2.00.0910271456410.14365@iabervon.org>
- In-Reply-To
- <alpine.DEB.1.00.0910271954020.11562@felix-maschine>
On Tue, 27 Oct 2009, Johannes Schindelin wrote:
Show 35 quoted lines
> Hi,
>
> On Tue, 27 Oct 2009, Daniel Barkalow wrote:
>
> > On Tue, 27 Oct 2009, Johannes Schindelin wrote:
> >
> > > Hi,
> > >
> > > On Tue, 27 Oct 2009, Daniel Barkalow wrote:
> > >
> > > > diff --git a/transport-helper.c b/transport-helper.c
> > > > index f57e84c..479539d 100644
> > > > --- a/transport-helper.c
> > > > +++ b/transport-helper.c
> > > > @@ -67,6 +67,13 @@ static int disconnect_helper(struct transport *transport)
> > > > return 0;
> > > > }
> > > >
> > > > +static int close_helper(struct transport *transport)
> > > > +{
> > > > + disconnect_helper(transport);
> > > > + free(transport->data);
> > > > + return 0;
> > > > +}
> > >
> > > Why did you not leech the transport->data = NULL; part from Peff/Sverre's
> > > patch?
> >
> > Because this code is only called just before transport itself is freed by
> > the caller, and, in general, a transport with these methods is invalid
> > without a valid transport->data. I expect that's also why Peff called it a
> > hack not appropriate for actual application.
>
> So you mean to imply that this method is not about closing, but about
> releasing the structure. Right?Yes, that's the word I was failing to come up with last night, thanks. Junio, "s/close/release/g" on that patch should improve comprehensibility greatly. (And changing the transport method name would probably also improve matters)
-Daniel *This .sig left intentionally blank*