Commit Diff


commit - ea83355f0a329b34b741dffc0cd0542ed96afb9a
commit + 35add24aa636945d591ac62534d3caf3e906621a
blob - 0a12db68e30bfecc944c4f8fb3458a22be23a38f
blob + 3b96469ab708761260c2a3efdf268310989076bd
--- lib/gitproto.c
+++ lib/gitproto.c
@@ -83,6 +83,10 @@ got_gitproto_parse_refline(char **id_str, char **refna
 	const struct got_error *err = NULL;
 	char *tokens[3];
 
+	*id_str = NULL;
+	*refname = NULL;
+	/* don't reset *server_capabilities */
+
 	err = tokenize_refline(tokens, line, len, nitems(tokens));
 	if (err)
 		return err;
@@ -92,11 +96,14 @@ got_gitproto_parse_refline(char **id_str, char **refna
 	if (tokens[1])
 		*refname = tokens[1];
 	if (tokens[2]) {
-		char *p;
-		*server_capabilities = tokens[2];
-		p = strrchr(*server_capabilities, '\n');
-		if (p)
-			*p = '\0';
+		if (*server_capabilities == NULL) {
+			char *p;
+			*server_capabilities = tokens[2];
+			p = strrchr(*server_capabilities, '\n');
+			if (p)
+				*p = '\0';
+		} else
+			free(tokens[2]);
 	}
 
 	return NULL;
blob - 9d5b83b348179ccd30d944a9e9e50183e0a4a458
blob + 65c075409a0f6850f37b585385b6429b80a143ed
--- libexec/got-fetch-pack/got-fetch-pack.c
+++ libexec/got-fetch-pack/got-fetch-pack.c
@@ -345,6 +345,8 @@ fetch_pack(int fd, int packfd, uint8_t *pack_sha1,
 			err = fetch_error(&buf[4], n - 4);
 			goto done;
 		}
+		free(id_str);
+		free(refname);
 		err = got_gitproto_parse_refline(&id_str, &refname,
 		    &server_capabilities, buf, n);
 		if (err)
blob - e0e012830f229855a13c1018058344c3045ff86a
blob + 5a7564d43fbe801786356a9a6036bb9372e66c68
--- libexec/got-send-pack/got-send-pack.c
+++ libexec/got-send-pack/got-send-pack.c
@@ -350,6 +350,8 @@ send_pack(int fd, struct got_pathlist_head *refs,
 			err = send_error(&buf[4], n - 4);
 			goto done;
 		}
+		free(id_str);
+		free(refname);
 		err = got_gitproto_parse_refline(&id_str, &refname,
 		    &server_capabilities, buf, n);
 		if (err)