transport-helper: fix strbuf leak in push_refs_with_push()

We loop over the refs to push, building up a strbuf with the set of "push" directives to send to the remote helper. But if the atomic-push flag is set and we hit a rejected ref, we'll bail from the function early. We clean up most things, but forgot to release the strbuf. Fixing this lets us mark t5541 as leak-free. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Sep 24, 2024 at 17:56 UTC e00e1cff0d845a66c58180d75c33be109a958ba3
2 files changed +2
t/t5541-http-push-smart.sh
+1
@@ -7,6 +7,7 @@ test_description='test smart pushing over http via http-backend'
7 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
8 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9
10 +TEST_PASSES_SANITIZE_LEAK=true
11 . ./test-lib.sh
12
13 ROOT_PATH="$PWD"
transport-helper.c
+1
@@ -1023,6 +1023,7 @@ static int push_refs_with_push(struct transport *transport,
1023 if (atomic) {
1024 reject_atomic_push(remote_refs, mirror);
1025 string_list_clear(&cas_options, 0);
1026 + strbuf_release(&buf);
1027 return 0;
1028 } else
1029 continue;