diff mbox series

[04/20] commit-graph: use free() instead of UNLEAK()

Message ID patch-04.20-5be87f9720c-20221228T175512Z-avarab@gmail.com (mailing list archive)
State Superseded
Headers show
Series leak fixes: various simple leak fixes | expand

Commit Message

Ævar Arnfjörð Bjarmason Dec. 28, 2022, 6 p.m. UTC
In 0bfb48e6723 (builtin/commit-graph.c: UNLEAK variables, 2018-10-03)
this was made to UNLEAK(), but we can just as easily free() the memory
instead.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/commit-graph.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

René Scharfe Dec. 28, 2022, 6:10 p.m. UTC | #1
Am 28.12.22 um 19:00 schrieb Ævar Arnfjörð Bjarmason:
> In 0bfb48e6723 (builtin/commit-graph.c: UNLEAK variables, 2018-10-03)
> this was made to UNLEAK(), but we can just as easily free() the memory
> instead.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  builtin/commit-graph.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
> index e8f77f535f3..b6e5726b082 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(graph);
Shouldn't this be "free_commit_graph(graph);" instead?

> +	return ret;
>  }
>
>  extern int read_replace_refs;
diff mbox series

Patch

diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index e8f77f535f3..b6e5726b082 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(graph);
+	return ret;
 }
 
 extern int read_replace_refs;