{"thread":{"id":"21851","subject":"[PATCH] builtin-push: don't access freed transport->url","startedAt":"2009-12-03T23:31:44Z","lastAt":"2009-12-04T00:31:03Z","messageCount":3,"participants":["Tay Ray Chuan","Daniel Barkalow","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"129148","messageId":"20091204073144.f98115f9.rctay89@gmail.com","threadId":"21851","inReplyTo":null,"subject":"[PATCH] builtin-push: don't access freed transport->url","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-12-03T23:31:44Z","receivedAt":"2009-12-03T23:31:44Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Move the failed push message to before transport_disconnect() so that\nit doesn't access transport->url after transport has been free()'d (in\ntransport_disconnect()).\n\nAdditionally, make the failed push message more accurate by moving it\nbefore transport_disconnect(), so that it doesn't report errors due\nto a failed disconnect.\n\nCc: \"Daniel Barkalow\" <barkalow@iabervon.org>\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n builtin-push.c |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-push.c b/builtin-push.c\nindex a21e46c..dcfb53f 100644\n--- a/builtin-push.c\n+++ b/builtin-push.c\n@@ -101,13 +101,14 @@ static int push_with_options(struct transport *transport, int flags)\n \t\tfprintf(stderr, \"Pushing to %s\\n\", transport->url);\n \terr = transport_push(transport, refspec_nr, refspec, flags,\n \t\t\t     &nonfastforward);\n+\tif (err != 0)\n+\t\terror(\"failed to push some refs to '%s'\", transport->url);\n+\n \terr |= transport_disconnect(transport);\n\n \tif (!err)\n \t\treturn 0;\n\n-\terror(\"failed to push some refs to '%s'\", transport->url);\n-\n \tif (nonfastforward && advice_push_nonfastforward) {\n \t\tprintf(\"To prevent you from losing history, non-fast-forward updates were rejected\\n\"\n \t\t       \"Merge the remote changes before pushing again.  See the 'non-fast-forward'\\n\"\n--\n1.6.6.rc1.249.g048b3\n"},{"id":"129149","messageId":"alpine.LNX.2.00.0912031837570.14365@iabervon.org","threadId":"21851","inReplyTo":"20091204073144.f98115f9.rctay89@gmail.com","subject":"Re: [PATCH] builtin-push: don't access freed transport->url","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-12-03T23:38:13Z","receivedAt":"2009-12-03T23:38:13Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Fri, 4 Dec 2009, Tay Ray Chuan wrote:\n\n> Move the failed push message to before transport_disconnect() so that\n> it doesn't access transport->url after transport has been free()'d (in\n> transport_disconnect()).\n> \n> Additionally, make the failed push message more accurate by moving it\n> before transport_disconnect(), so that it doesn't report errors due\n> to a failed disconnect.\n> \n> Cc: \"Daniel Barkalow\" <barkalow@iabervon.org>\n> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>\n\nAcked-by: Daniel Barkalow <barkalow@iabervon.org>\n\n> ---\n>  builtin-push.c |    5 +++--\n>  1 files changed, 3 insertions(+), 2 deletions(-)\n> \n> diff --git a/builtin-push.c b/builtin-push.c\n> index a21e46c..dcfb53f 100644\n> --- a/builtin-push.c\n> +++ b/builtin-push.c\n> @@ -101,13 +101,14 @@ static int push_with_options(struct transport *transport, int flags)\n>  \t\tfprintf(stderr, \"Pushing to %s\\n\", transport->url);\n>  \terr = transport_push(transport, refspec_nr, refspec, flags,\n>  \t\t\t     &nonfastforward);\n> +\tif (err != 0)\n> +\t\terror(\"failed to push some refs to '%s'\", transport->url);\n> +\n>  \terr |= transport_disconnect(transport);\n> \n>  \tif (!err)\n>  \t\treturn 0;\n> \n> -\terror(\"failed to push some refs to '%s'\", transport->url);\n> -\n>  \tif (nonfastforward && advice_push_nonfastforward) {\n>  \t\tprintf(\"To prevent you from losing history, non-fast-forward updates were rejected\\n\"\n>  \t\t       \"Merge the remote changes before pushing again.  See the 'non-fast-forward'\\n\"\n> --\n> 1.6.6.rc1.249.g048b3\n> \n"},{"id":"129152","messageId":"7vhbs71sxk.fsf@alter.siamese.dyndns.org","threadId":"21851","inReplyTo":"alpine.LNX.2.00.0912031837570.14365@iabervon.org","subject":"Re: [PATCH] builtin-push: don't access freed transport->url","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-04T00:31:03Z","receivedAt":"2009-12-04T00:31:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks, both; queued at the top of sr/vcs-helpers topic and merged to\n'next'.\n"}]}