Commit 2cf9b84cab373b9eb0a27aae027709a9a507a027

Etienne Samson 2018-04-11T19:13:42

smart: free the pkt when we fail to store it

diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index a1b56da..ab52e04 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -256,14 +256,15 @@ static int store_common(transport_smart *t)
 		if ((error = recv_pkt(&pkt, NULL, buf)) < 0)
 			return error;
 
-		if (pkt->type == GIT_PKT_ACK) {
-			if (git_vector_insert(&t->common, pkt) < 0)
-				return -1;
-		} else {
+		if (pkt->type != GIT_PKT_ACK) {
 			git__free(pkt);
 			return 0;
 		}
 
+		if (git_vector_insert(&t->common, pkt) < 0) {
+			git__free(pkt);
+			return -1;
+		}
 	} while (1);
 
 	return 0;