Commit 472e0cad8695f025daad2527ab1f6c0b813738c3

Stefan Sperling 2018-07-23T18:23:04

fix leaks in got's print_commits()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/got/got.c b/got/got.c
index 390d7ee..6954b08 100644
--- a/got/got.c
+++ b/got/got.c
@@ -451,12 +451,15 @@ print_commits(struct got_object *root_obj, struct got_object_id *root_id,
 					id = got_object_get_id(obj);
 					if (id == NULL) {
 						err = got_error_from_errno();
+						got_object_close(obj);
 						break;
 					}
 					pid = got_object_get_id(pobj);
 					if (pid == NULL) {
-						free(id);
 						err = got_error_from_errno();
+						free(id);
+						got_object_close(obj);
+						got_object_close(pobj);
 						break;
 					}
 					changed =