Git development
 help / color / mirror / Atom feed
* [PATCH] builtin-push: don't access freed transport->url
@ 2009-12-03 23:31 Tay Ray Chuan
  2009-12-03 23:38 ` Daniel Barkalow
  0 siblings, 1 reply; 3+ messages in thread
From: Tay Ray Chuan @ 2009-12-03 23:31 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Daniel Barkalow, Sverre Rabbelier, Junio C Hamano

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] builtin-push: don't access freed transport->url
  2009-12-03 23:31 [PATCH] builtin-push: don't access freed transport->url Tay Ray Chuan
@ 2009-12-03 23:38 ` Daniel Barkalow
  2009-12-04  0:31   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Barkalow @ 2009-12-03 23:38 UTC (permalink / raw)
  To: Tay Ray Chuan; +Cc: Git Mailing List, Sverre Rabbelier, Junio C Hamano

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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] builtin-push: don't access freed transport->url
  2009-12-03 23:38 ` Daniel Barkalow
@ 2009-12-04  0:31   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2009-12-04  0:31 UTC (permalink / raw)
  To: Daniel Barkalow
  Cc: Tay Ray Chuan, Git Mailing List, Sverre Rabbelier, Junio C Hamano

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-12-04  0:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-03 23:31 [PATCH] builtin-push: don't access freed transport->url Tay Ray Chuan
2009-12-03 23:38 ` Daniel Barkalow
2009-12-04  0:31   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox