mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-11 21:39:25 +00:00
net: plug a few memory leaks
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
This commit is contained in:
parent
546a3c8f9e
commit
8c2528748d
@ -389,15 +389,20 @@ static int on_body_parse_response(http_parser *parser, const char *str, size_t l
|
|||||||
git_buf_consume(buf, line_end);
|
git_buf_consume(buf, line_end);
|
||||||
|
|
||||||
if (pkt->type == GIT_PKT_PACK) {
|
if (pkt->type == GIT_PKT_PACK) {
|
||||||
|
free(pkt);
|
||||||
t->pack_ready = 1;
|
t->pack_ready = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pkt->type == GIT_PKT_NAK)
|
if (pkt->type == GIT_PKT_NAK) {
|
||||||
|
free(pkt);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (pkt->type != GIT_PKT_ACK)
|
if (pkt->type != GIT_PKT_ACK) {
|
||||||
|
free(pkt);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
error = git_vector_insert(common, pkt);
|
error = git_vector_insert(common, pkt);
|
||||||
if (error < GIT_SUCCESS)
|
if (error < GIT_SUCCESS)
|
||||||
@ -596,6 +601,8 @@ static int http_negotiate_fetch(git_transport *transport, git_repository *repo,
|
|||||||
} while(1);
|
} while(1);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
git_buf_free(&request);
|
||||||
|
git_buf_free(&data);
|
||||||
git_revwalk_free(walk);
|
git_revwalk_free(walk);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -722,6 +729,7 @@ static void http_free(git_transport *transport)
|
|||||||
{
|
{
|
||||||
transport_http *t = (transport_http *) transport;
|
transport_http *t = (transport_http *) transport;
|
||||||
git_vector *refs = &t->refs;
|
git_vector *refs = &t->refs;
|
||||||
|
git_vector *common = &t->common;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
git_pkt *p;
|
git_pkt *p;
|
||||||
|
|
||||||
@ -737,6 +745,10 @@ static void http_free(git_transport *transport)
|
|||||||
git_pkt_free(p);
|
git_pkt_free(p);
|
||||||
}
|
}
|
||||||
git_vector_free(refs);
|
git_vector_free(refs);
|
||||||
|
git_vector_foreach(common, i, p) {
|
||||||
|
git_pkt_free(p);
|
||||||
|
}
|
||||||
|
git_vector_free(common);
|
||||||
git_buf_free(&t->buf);
|
git_buf_free(&t->buf);
|
||||||
free(t->heads);
|
free(t->heads);
|
||||||
free(t->content_type);
|
free(t->content_type);
|
||||||
|
@ -357,9 +357,11 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g
|
|||||||
gitno_consume(buf, line_end);
|
gitno_consume(buf, line_end);
|
||||||
|
|
||||||
if (pkt->type == GIT_PKT_ACK) {
|
if (pkt->type == GIT_PKT_ACK) {
|
||||||
|
free(pkt);
|
||||||
error = GIT_SUCCESS;
|
error = GIT_SUCCESS;
|
||||||
goto done;
|
goto done;
|
||||||
} else if (pkt->type == GIT_PKT_NAK) {
|
} else if (pkt->type == GIT_PKT_NAK) {
|
||||||
|
free(pkt);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
error = git__throw(GIT_ERROR, "Got unexpected pkt type");
|
error = git__throw(GIT_ERROR, "Got unexpected pkt type");
|
||||||
@ -422,6 +424,7 @@ static int git_download_pack(char **out, git_transport *transport, git_repositor
|
|||||||
return error;
|
return error;
|
||||||
|
|
||||||
if (pkt->type == GIT_PKT_PACK) {
|
if (pkt->type == GIT_PKT_PACK) {
|
||||||
|
free(pkt);
|
||||||
return git_fetch__download_pack(out, buf->data, buf->offset, t->socket, repo);
|
return git_fetch__download_pack(out, buf->data, buf->offset, t->socket, repo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user