Skip to contentSkip to conversation

transport-helper: remove duplicate free()

PATCH In review Tay Ray Chuan 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 transport-helper: remove duplicate free()

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

---

Applies on top of 'next'.

 transport-helper.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
transport-helper.c +0 -1
index 9c5f860..2f77bd5 100644
@@ -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

#1 lore raw
Quoted 2 lines · Tay Ray Chuan

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*

#2 lore raw
Quoted 9 lines · Daniel Barkalow
Quoted 2 lines · Tay Ray Chuan

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.

#3 lore raw
In reply to Daniel Barkalow

Hi,

Quoted 4 lines · Daniel Barkalow

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).

Signature · 2 lines
Cheers,
Ray Chuan