Commit 8c252874 by Carlos Martín Nieto Committed by Vicent Marti

net: plug a few memory leaks

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
parent 546a3c8f
......@@ -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);
if (pkt->type == GIT_PKT_PACK) {
free(pkt);
t->pack_ready = 1;
return 0;
}
if (pkt->type == GIT_PKT_NAK)
if (pkt->type == GIT_PKT_NAK) {
free(pkt);
return 0;
}
if (pkt->type != GIT_PKT_ACK)
if (pkt->type != GIT_PKT_ACK) {
free(pkt);
continue;
}
error = git_vector_insert(common, pkt);
if (error < GIT_SUCCESS)
......@@ -596,6 +601,8 @@ static int http_negotiate_fetch(git_transport *transport, git_repository *repo,
} while(1);
cleanup:
git_buf_free(&request);
git_buf_free(&data);
git_revwalk_free(walk);
return error;
}
......@@ -722,6 +729,7 @@ static void http_free(git_transport *transport)
{
transport_http *t = (transport_http *) transport;
git_vector *refs = &t->refs;
git_vector *common = &t->common;
unsigned int i;
git_pkt *p;
......@@ -737,6 +745,10 @@ static void http_free(git_transport *transport)
git_pkt_free(p);
}
git_vector_free(refs);
git_vector_foreach(common, i, p) {
git_pkt_free(p);
}
git_vector_free(common);
git_buf_free(&t->buf);
free(t->heads);
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);
if (pkt->type == GIT_PKT_ACK) {
free(pkt);
error = GIT_SUCCESS;
goto done;
} else if (pkt->type == GIT_PKT_NAK) {
free(pkt);
break;
} else {
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;
if (pkt->type == GIT_PKT_PACK) {
free(pkt);
return git_fetch__download_pack(out, buf->data, buf->offset, t->socket, repo);
}
......
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