builtin-push: don't access freed transport->url
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. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tay Ray Chuan committed
Dec 4, 2009 at 07:31 UTC
53970b92d9dc883669f3a9b79b5e39e73931b331
1 file changed
+3
-2
builtin-push.c
+3
-2
@@ -102,13 +102,14 @@ static int push_with_options(struct transport *transport, int flags)
102
fprintf(stderr, "Pushing to %s\n", transport->url);
103
err = transport_push(transport, refspec_nr, refspec, flags,
104
&nonfastforward);
105
+ if (err != 0)
106
+ error("failed to push some refs to '%s'", transport->url);
107
+
108
err |= transport_disconnect(transport);
109
110
if (!err)
111
return 0;
112
110
- error("failed to push some refs to '%s'", transport->url);
111
-
113
if (nonfastforward && advice_push_nonfastforward) {
114
printf("To prevent you from losing history, non-fast-forward updates were rejected\n"
115
"Merge the remote changes before pushing again. See the 'non-fast-forward'\n"