# [PATCH] transport-helper: remove duplicate free()

4 messages from 2009-12-02 to 2009-12-02. Participants: Tay Ray Chuan, Daniel Barkalow, Junio C Hamano.
Thread: https://gitlist.dev/t/21820

## Tay Ray Chuan, 2009-12-02 07:39

Subject: [PATCH] transport-helper: remove duplicate free()
Message-ID: <20091202153950.c18095b7.rctay89@gmail.com>
URL: https://gitlist.dev/e/20091202153950.c18095b7.rctay89%40gmail.com

```
Remove the free() invocation on transport->data in release_helper(), as
disconnect_helper() has already done so.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---

  Applies on top of 'next'.

 transport-helper.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/transport-helper.c b/transport-helper.c
index 9c5f860..2f77bd5 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -196,7 +196,6 @@ static int release_helper(struct transport *transport)
 	free_refspec(data->refspec_nr, data->refspecs);
 	data->refspecs = NULL;
 	disconnect_helper(transport);
-	free(transport->data);
 	return 0;
 }

--
1.6.6.rc0.306.g5bb1c0

```

## Daniel Barkalow, 2009-12-02 16:23

Subject: Re: [PATCH] transport-helper: remove duplicate free()
Message-ID: <alpine.LNX.2.00.0912021120440.14365@iabervon.org>
URL: https://gitlist.dev/e/alpine.LNX.2.00.0912021120440.14365%40iabervon.org
In-Reply-To: <20091202153950.c18095b7.rctay89@gmail.com>

```
On Wed, 2 Dec 2009, Tay Ray Chuan wrote:

> Remove the free() invocation on transport->data in release_helper(), as
> disconnect_helper() has already done so.

You need to remove the one in disconnect_helper, because the entire point 
of disconnect_helper as opposed to release_helper is to *not* free that 
memory. If you remove this one, you'll access freed memory in any case 
where the helper has to be quit and restarted.

	-Daniel
*This .sig left intentionally blank*

```

## Junio C Hamano, 2009-12-02 19:06

Subject: Re: [PATCH] transport-helper: remove duplicate free()
Message-ID: <7vws15ci0s.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vws15ci0s.fsf%40alter.siamese.dyndns.org
In-Reply-To: <alpine.LNX.2.00.0912021120440.14365@iabervon.org>

```
Daniel Barkalow <barkalow@iabervon.org> writes:

> On Wed, 2 Dec 2009, Tay Ray Chuan wrote:
>
>> Remove the free() invocation on transport->data in release_helper(), as
>> disconnect_helper() has already done so.
>
> You need to remove the one in disconnect_helper, because the entire point 
> of disconnect_helper as opposed to release_helper is to *not* free that 
> memory. If you remove this one, you'll access freed memory in any case 
> where the helper has to be quit and restarted.

Thanks.  I did two things:

 - Since the bottom commit cannot be rewritten (as it is based on the
   version that is before the change in the caller to free it), I queued a
   one liner to remove the free from the callee in 'next'.

 - The problem will surface when the series is later merged to 'master'.
   I told my rerere database about the necessity of this "evil merge", so
   that we will automatically have the equivalent of the one-liner when it
   happens.

```

## Tay Ray Chuan, 2009-12-02 23:00

Subject: Re: [PATCH] transport-helper: remove duplicate free()
Message-ID: <be6fef0d0912021500w313ac170m65251f7b8a4fa1de@mail.gmail.com>
URL: https://gitlist.dev/e/be6fef0d0912021500w313ac170m65251f7b8a4fa1de%40mail.gmail.com
In-Reply-To: <alpine.LNX.2.00.0912021120440.14365@iabervon.org>

```
Hi,

On Thu, Dec 3, 2009 at 12:23 AM, Daniel Barkalow <barkalow@iabervon.org> wrote:
> You need to remove the one in disconnect_helper, because the entire point
> of disconnect_helper as opposed to release_helper is to *not* free that
> memory. If you remove this one, you'll access freed memory in any case
> where the helper has to be quit and restarted.

I see. I guess I should have looked more closely at f2a3715 (Fix
memory leak in helper method for disconnect).

-- 
Cheers,
Ray Chuan

```
