1
0
mirror of https://github.com/git/git.git synced 2024-10-18 12:18:44 +02:00

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>
This commit is contained in:
Jeff King 2024-09-24 17:56:34 -04:00 committed by Junio C Hamano
parent 05372c28be
commit e00e1cff0d
2 changed files with 2 additions and 0 deletions

@ -7,6 +7,7 @@ test_description='test smart pushing over http via http-backend'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
ROOT_PATH="$PWD"

@ -1023,6 +1023,7 @@ static int push_refs_with_push(struct transport *transport,
if (atomic) {
reject_atomic_push(remote_refs, mirror);
string_list_clear(&cas_options, 0);
strbuf_release(&buf);
return 0;
} else
continue;