diff options
Diffstat (limited to 'src/transports/local.c')
-rw-r--r-- | src/transports/local.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/transports/local.c b/src/transports/local.c index 05302a13f..c544fa935 100644 --- a/src/transports/local.c +++ b/src/transports/local.c @@ -47,6 +47,17 @@ static void free_head(git_remote_head *head) git__free(head); } +static void free_heads(git_vector *heads) +{ + git_remote_head *head; + size_t i; + + git_vector_foreach(heads, i, head) + free_head(head); + + git_vector_free(heads); +} + static int add_ref(transport_local *t, const char *name) { const char peeled[] = "^{}"; @@ -198,6 +209,8 @@ static int local_connect( if (t->connected) return 0; + free_heads(&t->refs); + t->url = git__strdup(url); GITERR_CHECK_ALLOC(t->url); t->direction = direction; @@ -624,13 +637,8 @@ static int local_close(git_transport *transport) static void local_free(git_transport *transport) { transport_local *t = (transport_local *)transport; - size_t i; - git_remote_head *head; - git_vector_foreach(&t->refs, i, head) - free_head(head); - - git_vector_free(&t->refs); + free_heads(&t->refs); /* Close the transport, if it's still open. */ local_close(transport); |