wait_while_ack: use git_pkt_free git__free is insufficient if the packet is a git_pkt_ref or another type that requires freeing referenced structures.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 8a094b6..9bf2883 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -317,27 +317,34 @@ on_error:
static int wait_while_ack(gitno_buffer *buf)
{
int error;
- git_pkt_ack *pkt = NULL;
+ git_pkt *pkt = NULL;
+ git_pkt_ack *ack = NULL;
while (1) {
- git__free(pkt);
+ if (pkt) {
+ git_pkt_free(pkt);
+ }
- if ((error = recv_pkt((git_pkt **)&pkt, NULL, buf)) < 0)
+ if ((error = recv_pkt(&pkt, NULL, buf)) < 0)
return error;
if (pkt->type == GIT_PKT_NAK)
break;
+ if (pkt->type != GIT_PKT_ACK)
+ continue;
- if (pkt->type == GIT_PKT_ACK &&
- (pkt->status != GIT_ACK_CONTINUE &&
- pkt->status != GIT_ACK_COMMON &&
- pkt->status != GIT_ACK_READY)) {
- git__free(pkt);
- return 0;
+ ack = (git_pkt_ack*)pkt;
+
+ if (ack->status != GIT_ACK_CONTINUE &&
+ ack->status != GIT_ACK_COMMON &&
+ ack->status != GIT_ACK_READY) {
+ break;
}
}
- git__free(pkt);
+ if (pkt) {
+ git_pkt_free(pkt);
+ }
return 0;
}