From e8ed0a8ac5ecb4379018e78188ed3ff489c7cfc5 Mon Sep 17 00:00:00 2001 From: Ævar Arnfjörð Bjarmason Date: Tue, 7 Feb 2023 00:07:38 +0100 Subject: commit-graph: use free_commit_graph() instead of UNLEAK() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In 0bfb48e6723 (builtin/commit-graph.c: UNLEAK variables, 2018-10-03) this was made to UNLEAK(), but we can just as easily invoke the free_commit_graph() function added in c3756d5b7fc (commit-graph: add free_commit_graph, 2018-07-11) instead. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/commit-graph.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'builtin/commit-graph.c') diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index e8f77f535f..0102ac8540 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -67,6 +67,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix) int fd; struct stat st; int flags = 0; + int ret; static struct option builtin_commit_graph_verify_options[] = { OPT_BOOL(0, "shallow", &opts.shallow, @@ -111,8 +112,9 @@ static int graph_verify(int argc, const char **argv, const char *prefix) if (!graph) return !!open_ok; - UNLEAK(graph); - return verify_commit_graph(the_repository, graph, flags); + ret = verify_commit_graph(the_repository, graph, flags); + free_commit_graph(graph); + return ret; } extern int read_replace_refs; -- cgit 1.2.3-korg From 9d01cfed6915b1e99c266fd578e39c7aba7767dc Mon Sep 17 00:00:00 2001 From: Ævar Arnfjörð Bjarmason Date: Tue, 7 Feb 2023 00:07:46 +0100 Subject: commit-graph: fix a parse_options_concat() leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the parse_options_concat() was added to this file in 84e4484f128 (commit-graph: use parse_options_concat(), 2021-08-23) we wouldn't free() it if we returned early in these cases. Since "result" is 0 by default we can "goto cleanup" in both cases, and only need to set "result" if write_commit_graph_reachable() fails. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/commit-graph.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin/commit-graph.c') diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index 0102ac8540..93704f95a9 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -269,8 +269,8 @@ static int graph_write(int argc, const char **argv, const char *prefix) if (opts.reachable) { if (write_commit_graph_reachable(odb, flags, &write_opts)) - return 1; - return 0; + result = 1; + goto cleanup; } if (opts.stdin_packs) { -- cgit 1.2.3-korg