]> git.ipfire.org Git - thirdparty/git.git/commitdiff
send-pack: clean-up even when taking an early exit
authorJunio C Hamano <gitster@pobox.com>
Tue, 1 Jul 2025 21:17:25 +0000 (14:17 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 1 Jul 2025 21:17:25 +0000 (14:17 -0700)
Previous commit has plugged one leak in the normal code path, but
there is an early exit that leaves without releasing any resources
acquired in the function.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/send-pack.c

index b28da7ddd7619e0fb570bf8c7a2b49c129835c38..6ce9f6665a524cd96e464d4a68809cff385324f4 100644 (file)
@@ -305,9 +305,10 @@ int cmd_send_pack(int argc,
                flags |= MATCH_REFS_MIRROR;
 
        /* match them up */
-       if (match_push_refs(local_refs, &remote_refs, &rs, flags))
-               return -1;
-
+       if (match_push_refs(local_refs, &remote_refs, &rs, flags)) {
+               ret = -1;
+               goto cleanup;
+       }
        if (!is_empty_cas(&cas))
                apply_push_cas(&cas, remote, remote_refs);
 
@@ -340,6 +341,7 @@ int cmd_send_pack(int argc,
                /* stable plumbing output; do not modify or localize */
                fprintf(stderr, "Everything up-to-date\n");
 
+cleanup:
        string_list_clear(&push_options, 0);
        free_refs(remote_refs);
        free_refs(local_refs);