threads / patch / 21820

patchtransport-helper: remove duplicate free()

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

## tl;dr

4 messages between Dec 2, 2009 and Dec 2, 2009. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Tay Ray Chuan· Dec 2, 2009, 07:39 UTC · lore

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(-)
Show changes to transport-helper.c +0 −2
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· Dec 2, 2009, 16:23 UTC · re: Tay Ray Chuan · lore

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

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· Dec 2, 2009, 19:06 UTC · re: Daniel Barkalow · lore

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

Daniel Barkalow <barkalow@iabervon.org> writes:
Show 9 quoted lines
> 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· Dec 2, 2009, 23:00 UTC · re: Daniel Barkalow · lore

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

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

← back to recent threads