Commit 3a547417 by Nelson Elhage

git_pkt_free: Allow freeing NULL

parent d58afb17
......@@ -483,6 +483,9 @@ int git_pkt_parse_line(
void git_pkt_free(git_pkt *pkt)
{
if (pkt == NULL) {
return;
}
if (pkt->type == GIT_PKT_REF) {
git_pkt_ref *p = (git_pkt_ref *) pkt;
git__free(p->head.name);
......
......@@ -321,9 +321,7 @@ static int wait_while_ack(gitno_buffer *buf)
git_pkt_ack *ack = NULL;
while (1) {
if (pkt) {
git_pkt_free(pkt);
}
if ((error = recv_pkt(&pkt, NULL, buf)) < 0)
return error;
......@@ -342,9 +340,7 @@ static int wait_while_ack(gitno_buffer *buf)
}
}
if (pkt) {
git_pkt_free(pkt);
}
return 0;
}
......@@ -622,9 +618,8 @@ int git_smart__download_pack(
}
}
if (pkt) {
git_pkt_free(pkt);
}
if (error < 0)
goto done;
......
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