Commit d3d493d784c530e35d0142f76d125108b72619bb

Stefan Sperling 2019-02-21T22:57:29

got: fix memory leak in print_commit()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/got/got.c b/got/got.c
index ed6be66..37ac5ae 100644
--- a/got/got.c
+++ b/got/got.c
@@ -650,6 +650,9 @@ print_commit(struct got_commit_object *commit, struct got_object_id *id,
 	printf("commit %s%s%s%s\n", id_str, refs_str ? " (" : "",
 	    refs_str ? refs_str : "", refs_str ? ")" : "");
 	free(id_str);
+	id_str = NULL;
+	free(refs_str);
+	refs_str = NULL;
 	printf("from: %s\n", got_object_commit_get_author(commit));
 	committer_time = got_object_commit_get_committer_time(commit);
 	datestr = get_datestr(&committer_time, datebuf);