Fix a leak in the local transport code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/src/transports/local.c b/src/transports/local.c
index 4bf1c87..5500609 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -571,6 +571,8 @@ static void local_cancel(git_transport *transport)
static int local_close(git_transport *transport)
{
transport_local *t = (transport_local *)transport;
+ size_t i;
+ git_remote_head *head;
t->connected = 0;
@@ -584,25 +586,23 @@ static int local_close(git_transport *transport)
t->url = NULL;
}
+ git_vector_foreach(&t->refs, i, head) {
+ git__free(head->name);
+ git__free(head);
+ }
+
+ git_vector_free(&t->refs);
+
return 0;
}
static void local_free(git_transport *transport)
{
transport_local *t = (transport_local *)transport;
- size_t i;
- git_remote_head *head;
/* Close the transport, if it's still open. */
local_close(transport);
- git_vector_foreach(&t->refs, i, head) {
- git__free(head->name);
- git__free(head);
- }
-
- git_vector_free(&t->refs);
-
/* Free the transport */
git__free(t);
}