summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Kelley <phkelley@hotmail.com>2012-11-23 15:30:58 -0500
committerPhilip Kelley <phkelley@hotmail.com>2012-11-23 15:30:58 -0500
commit58fe189149a95c1ab25eaae7372f9b1002fc5770 (patch)
treea6cda9220a7edb5a67e3adf4f121950d514e9b51
parent71c73def2d21eb0bbd230fd70f4cc31604e9254a (diff)
downloadlibgit2-features/push.tar.gz
Squash some leaksfeatures/push
-rw-r--r--src/transports/smart.c4
-rw-r--r--src/transports/smart_protocol.c15
2 files changed, 15 insertions, 4 deletions
diff --git a/src/transports/smart.c b/src/transports/smart.c
index b6ee8d942..5ab51d068 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -128,8 +128,10 @@ static int git_smart__connect(
/* 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 99578f462..38ddeb952 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -651,6 +651,7 @@ int git_smart__push(git_transport *transport, git_push *push)
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 @@ int git_smart__push(git_transport *transport, git_push *push)
/* 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;