Commit 3f7f9bd96eb735d35591a1e66f70adcabfc86cc6

Stefan Sperling 2020-01-06T15:50:36

fix memleak in error case of got-read-commit

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/libexec/got-read-commit/got-read-commit.c b/libexec/got-read-commit/got-read-commit.c
index 19ddcf4..3ec8615 100644
--- a/libexec/got-read-commit/got-read-commit.c
+++ b/libexec/got-read-commit/got-read-commit.c
@@ -60,8 +60,10 @@ read_commit_object(struct got_commit_object **commit, FILE *f)
 		return err;
 
 	err = got_object_parse_header(&obj, p, len);
-	if (err)
+	if (err) {
+		free(p);
 		return err;
+	}
 
 	if (len < obj->hdrlen + obj->size) {
 		err = got_error(GOT_ERR_BAD_OBJ_DATA);