]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph: fix a parse_options_concat() leak
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 6 Feb 2023 23:07:46 +0000 (00:07 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Feb 2023 23:34:38 +0000 (15:34 -0800)
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 <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit-graph.c

index 0102ac8540ead7d565acf2cb97a1746eb14378d0..93704f95a9da8ab8313e7a17589153951e3bb9fe 100644 (file)
@@ -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) {