Commit 4d0fef1df5fd36438be6d5f1cd6889640ab28c13

Stefan Sperling 2020-03-18T16:13:44

plug a memory leak in resolve_deltified_object()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/libexec/got-index-pack/got-index-pack.c b/libexec/got-index-pack/got-index-pack.c
index 444ad15..a6cace5 100644
--- a/libexec/got-index-pack/got-index-pack.c
+++ b/libexec/got-index-pack/got-index-pack.c
@@ -284,7 +284,7 @@ resolve_deltified_object(struct got_pack *pack, struct got_packidx *packidx,
 	uint8_t *buf = NULL;
 	size_t len;
 	SHA1_CTX ctx;
-	char *header;
+	char *header = NULL;
 	size_t headerlen;
 	int base_obj_type;
 	const char *obj_label;
@@ -321,6 +321,7 @@ resolve_deltified_object(struct got_pack *pack, struct got_packidx *packidx,
 	SHA1Final(obj->id.sha1, &ctx);
 done:
 	free(buf);
+	free(header);
 	while (!SIMPLEQ_EMPTY(&deltas.entries)) {
 		delta = SIMPLEQ_FIRST(&deltas.entries);
 		SIMPLEQ_REMOVE_HEAD(&deltas.entries, entry);