Commit a2888919 by Carlos Martín Nieto

local transport: don't segfault on wrong URL

memset the structure on initialisation and don't try to dereference
the vector with the heads if we didn't find a repository.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
parent ccc9872d
...@@ -201,16 +201,19 @@ static void local_free(git_transport *transport) ...@@ -201,16 +201,19 @@ static void local_free(git_transport *transport)
unsigned int i; unsigned int i;
transport_local *t = (transport_local *) transport; transport_local *t = (transport_local *) transport;
git_vector *vec = t->refs; git_vector *vec = t->refs;
git_remote_head *h;
assert(transport); assert(transport);
for (i = 0; i < vec->length; ++i) { if (t->refs != NULL) {
git_remote_head *h = git_vector_get(vec, i); git_vector_foreach (vec, i, h) {
free(h->name); free(h->name);
free(h); free(h);
}
git_vector_free(vec);
free(vec);
} }
git_vector_free(vec);
free(vec);
git_repository_free(t->repo); git_repository_free(t->repo);
free(t->parent.url); free(t->parent.url);
free(t); free(t);
...@@ -228,6 +231,8 @@ int git_transport_local(git_transport **out) ...@@ -228,6 +231,8 @@ int git_transport_local(git_transport **out)
if (t == NULL) if (t == NULL)
return GIT_ENOMEM; return GIT_ENOMEM;
memset(t, 0x0, sizeof(transport_local));
t->parent.connect = local_connect; t->parent.connect = local_connect;
t->parent.ls = local_ls; t->parent.ls = local_ls;
t->parent.send_wants = local_send_wants; t->parent.send_wants = local_send_wants;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment