Commit 8f7fc2ee by Edward Thomson

shallow: avoid unnecessary pkt free

Looks like a double-free here.
parent d69c7a72
...@@ -408,27 +408,29 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c ...@@ -408,27 +408,29 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
goto on_error; goto on_error;
while ((error = recv_pkt((git_pkt **)&pkt, NULL, t, buf)) == 0) { while ((error = recv_pkt((git_pkt **)&pkt, NULL, t, buf)) == 0) {
bool complete = false;
if (pkt->type == GIT_PKT_SHALLOW) { if (pkt->type == GIT_PKT_SHALLOW) {
git_shallowarray_add(wants->shallow_roots, &pkt->oid); git_shallowarray_add(wants->shallow_roots, &pkt->oid);
} else if (pkt->type == GIT_PKT_UNSHALLOW) { } else if (pkt->type == GIT_PKT_UNSHALLOW) {
git_shallowarray_remove(wants->shallow_roots, &pkt->oid); git_shallowarray_remove(wants->shallow_roots, &pkt->oid);
} else if (pkt->type == GIT_PKT_FLUSH) { } else if (pkt->type == GIT_PKT_FLUSH) {
/* Server is done, stop processing shallow oids */ /* Server is done, stop processing shallow oids */
break; complete = true;
} else { } else {
git_error_set(GIT_ERROR_NET, "Unexpected pkt type"); git_error_set(GIT_ERROR_NET, "unexpected packet type");
goto on_error; error = -1;
} }
git_pkt_free((git_pkt *) pkt); git_pkt_free((git_pkt *) pkt);
}
git_pkt_free((git_pkt *) pkt); if (complete || error < 0)
break;
}
if (error < 0) { if (error < 0)
goto on_error; goto on_error;
} }
}
/* /*
* Our support for ACK extensions is simply to parse them. On * Our support for ACK extensions is simply to parse them. On
* the first ACK we will accept that as enough common * the first ACK we will accept that as enough common
......
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