# [PATCH] builtin-push: don't access freed transport->url

3 messages from 2009-12-03 to 2009-12-04. Participants: Tay Ray Chuan, Daniel Barkalow, Junio C Hamano.
Thread: https://gitlist.dev/t/21851

## Tay Ray Chuan, 2009-12-03 23:31

Subject: [PATCH] builtin-push: don't access freed transport->url
Message-ID: <20091204073144.f98115f9.rctay89@gmail.com>
URL: https://gitlist.dev/e/20091204073144.f98115f9.rctay89%40gmail.com

```
Move the failed push message to before transport_disconnect() so that
it doesn't access transport->url after transport has been free()'d (in
transport_disconnect()).

Additionally, make the failed push message more accurate by moving it
before transport_disconnect(), so that it doesn't report errors due
to a failed disconnect.

Cc: "Daniel Barkalow" <barkalow@iabervon.org>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 builtin-push.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/builtin-push.c b/builtin-push.c
index a21e46c..dcfb53f 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -101,13 +101,14 @@ static int push_with_options(struct transport *transport, int flags)
 		fprintf(stderr, "Pushing to %s\n", transport->url);
 	err = transport_push(transport, refspec_nr, refspec, flags,
 			     &nonfastforward);
+	if (err != 0)
+		error("failed to push some refs to '%s'", transport->url);
+
 	err |= transport_disconnect(transport);

 	if (!err)
 		return 0;

-	error("failed to push some refs to '%s'", transport->url);
-
 	if (nonfastforward && advice_push_nonfastforward) {
 		printf("To prevent you from losing history, non-fast-forward updates were rejected\n"
 		       "Merge the remote changes before pushing again.  See the 'non-fast-forward'\n"
--
1.6.6.rc1.249.g048b3

```

## Daniel Barkalow, 2009-12-03 23:38

Subject: Re: [PATCH] builtin-push: don't access freed transport->url
Message-ID: <alpine.LNX.2.00.0912031837570.14365@iabervon.org>
URL: https://gitlist.dev/e/alpine.LNX.2.00.0912031837570.14365%40iabervon.org
In-Reply-To: <20091204073144.f98115f9.rctay89@gmail.com>

```
On Fri, 4 Dec 2009, Tay Ray Chuan wrote:

> Move the failed push message to before transport_disconnect() so that
> it doesn't access transport->url after transport has been free()'d (in
> transport_disconnect()).
> 
> Additionally, make the failed push message more accurate by moving it
> before transport_disconnect(), so that it doesn't report errors due
> to a failed disconnect.
> 
> Cc: "Daniel Barkalow" <barkalow@iabervon.org>
> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>

Acked-by: Daniel Barkalow <barkalow@iabervon.org>

> ---
>  builtin-push.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/builtin-push.c b/builtin-push.c
> index a21e46c..dcfb53f 100644
> --- a/builtin-push.c
> +++ b/builtin-push.c
> @@ -101,13 +101,14 @@ static int push_with_options(struct transport *transport, int flags)
>  		fprintf(stderr, "Pushing to %s\n", transport->url);
>  	err = transport_push(transport, refspec_nr, refspec, flags,
>  			     &nonfastforward);
> +	if (err != 0)
> +		error("failed to push some refs to '%s'", transport->url);
> +
>  	err |= transport_disconnect(transport);
> 
>  	if (!err)
>  		return 0;
> 
> -	error("failed to push some refs to '%s'", transport->url);
> -
>  	if (nonfastforward && advice_push_nonfastforward) {
>  		printf("To prevent you from losing history, non-fast-forward updates were rejected\n"
>  		       "Merge the remote changes before pushing again.  See the 'non-fast-forward'\n"
> --
> 1.6.6.rc1.249.g048b3
> 

```

## Junio C Hamano, 2009-12-04 00:31

Subject: Re: [PATCH] builtin-push: don't access freed transport->url
Message-ID: <7vhbs71sxk.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vhbs71sxk.fsf%40alter.siamese.dyndns.org
In-Reply-To: <alpine.LNX.2.00.0912031837570.14365@iabervon.org>

```
Thanks, both; queued at the top of sr/vcs-helpers topic and merged to
'next'.

```
