]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin-push.c
builtin-push: don't access freed transport->url
[thirdparty/git.git] / builtin-push.c
index 9846c638a611c07a98598464a7c72c4d8120fcea..03be045baed585d4d3996b0d16ea96cf79e2a584 100644 (file)
@@ -102,13 +102,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"