send-pack: clean-up even when taking an early exit
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>
Junio C Hamano committed
Jul 1, 2025 at 14:17 UTC
b0e9d258654bb2c50f095ba05599d8badadb71a2
1 file changed
+5
-3
builtin/send-pack.c
+5
-3
@@ -305,9 +305,10 @@ int cmd_send_pack(int argc,
305
flags |= MATCH_REFS_MIRROR;
306
307
/* match them up */
308
- if (match_push_refs(local_refs, &remote_refs, &rs, flags))
309
- return -1;
310
-
308
+ if (match_push_refs(local_refs, &remote_refs, &rs, flags)) {
309
+ ret = -1;
310
+ goto cleanup;
311
+ }
312
if (!is_empty_cas(&cas))
313
apply_push_cas(&cas, remote, remote_refs);
314
@@ -340,6 +341,7 @@ int cmd_send_pack(int argc,
341
/* stable plumbing output; do not modify or localize */
342
fprintf(stderr, "Everything up-to-date\n");
343
344
+cleanup:
345
string_list_clear(&push_options, 0);
346
free_refs(remote_refs);
347
free_refs(local_refs);