Commit b0f7512f407284c9eec91681a7ced5c93e026644

Patrick Steinhardt 2016-02-15T11:46:10

transports: smart_pkt: fix memory leaks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;