transports: smart_pkt: fix memory leaks
diff --git a/src/transports/smart_pkt.c b/src/transports/smart_pkt.c
index a6ae55d..870f084 100644
--- a/src/transports/smart_pkt.c
+++ b/src/transports/smart_pkt.c
@@ -271,6 +271,7 @@ static int ok_pkt(git_pkt **out, const char *line, size_t len)
line += 3; /* skip "ok " */
if (!(ptr = strchr(line, '\n'))) {
giterr_set(GITERR_NET, "Invalid packet line");
+ git__free(pkt);
return -1;
}
len = ptr - line;
@@ -314,6 +315,8 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
line = ptr + 1;
if (!(ptr = strchr(line, '\n'))) {
giterr_set(GITERR_NET, "Invalid packet line");
+ git__free(pkt->ref);
+ git__free(pkt);
return -1;
}
len = ptr - line;