mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-03 02:49:09 +00:00
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>
This commit is contained in:
parent
ccc9872d4d
commit
a28889198c
@ -201,16 +201,19 @@ static void local_free(git_transport *transport)
|
||||
unsigned int i;
|
||||
transport_local *t = (transport_local *) transport;
|
||||
git_vector *vec = t->refs;
|
||||
git_remote_head *h;
|
||||
|
||||
assert(transport);
|
||||
|
||||
for (i = 0; i < vec->length; ++i) {
|
||||
git_remote_head *h = git_vector_get(vec, i);
|
||||
free(h->name);
|
||||
free(h);
|
||||
if (t->refs != NULL) {
|
||||
git_vector_foreach (vec, i, h) {
|
||||
free(h->name);
|
||||
free(h);
|
||||
}
|
||||
git_vector_free(vec);
|
||||
free(vec);
|
||||
}
|
||||
git_vector_free(vec);
|
||||
free(vec);
|
||||
|
||||
git_repository_free(t->repo);
|
||||
free(t->parent.url);
|
||||
free(t);
|
||||
@ -228,6 +231,8 @@ int git_transport_local(git_transport **out)
|
||||
if (t == NULL)
|
||||
return GIT_ENOMEM;
|
||||
|
||||
memset(t, 0x0, sizeof(transport_local));
|
||||
|
||||
t->parent.connect = local_connect;
|
||||
t->parent.ls = local_ls;
|
||||
t->parent.send_wants = local_send_wants;
|
||||
|
Loading…
Reference in New Issue
Block a user