Squash some leaks
diff --git a/src/transports/smart.c b/src/transports/smart.c
index b6ee8d9..5ab51d0 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -128,8 +128,10 @@
 
 	/* If the only ref in the list is capabilities^{} with OID_ZERO, remove it */
 	if (1 == t->refs.length && !strcmp(first->head.name, "capabilities^{}") &&
-		git_oid_iszero(&first->head.oid))
+		git_oid_iszero(&first->head.oid)) {
 		git_vector_clear(&t->refs);
+		git_pkt_free((git_pkt *)first);
+	}
 
 	if (t->rpc && git_smart__reset_stream(t, false) < 0)
 		return -1;
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 99578f4..38ddeb9 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -651,6 +651,7 @@
 	transport_smart *t = (transport_smart *)transport;
 	git_smart_subtransport_stream *s;
 	git_buf pktline = GIT_BUF_INIT;
+	char *url = NULL;
 	int error = -1;
 
 #ifdef PUSH_DEBUG
@@ -691,13 +692,21 @@
 	/* If we updated at least one ref, then we need to re-acquire the list of 
 	 * refs so the caller can call git_remote_update_tips afterward. TODO: Use
 	 * the data from the push report to do this without another network call */
-	if (push->specs.length &&
-		t->parent.connect(&t->parent, t->url, t->cred_acquire_cb, GIT_DIR_PUSH, t->flags) < 0)
-		goto on_error;
+	if (push->specs.length) {
+		git_cred_acquire_cb cred_cb = t->cred_acquire_cb;
+		int flags = t->flags;
+
+		url = git__strdup(t->url);
+
+		if (!url || t->parent.close(&t->parent) < 0 ||
+			t->parent.connect(&t->parent, url, cred_cb, GIT_DIR_PUSH, flags))
+			goto on_error;
+	}
 
 	error = 0;
 
 on_error:
+	git__free(url);
 	git_buf_free(&pktline);
 
 	return error;