Commit 7cd14ea0da6f3f85fa7bf27fc123e5b05ffc8009

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

plug memory leak in error path of read_packed_object()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/libexec/got-index-pack/got-index-pack.c b/libexec/got-index-pack/got-index-pack.c
index c491967..ece294c 100644
--- a/libexec/got-index-pack/got-index-pack.c
+++ b/libexec/got-index-pack/got-index-pack.c
@@ -190,8 +190,10 @@ read_packed_object(struct got_pack *pack, struct got_indexed_object *obj)
 			break;
 		SHA1Init(&ctx);
 		err = get_obj_type_label(&obj_label, obj->type);
-		if (err)
+		if (err) {
+			free(data);
 			break;
+		}
 		if (asprintf(&header, "%s %lld", obj_label, obj->size) == -1) {
 			err = got_error_from_errno("asprintf");
 			free(data);