]> git.ipfire.org Git - thirdparty/git.git/commitdiff
transport-helper: fix strbuf leak in push_refs_with_push()
authorJeff King <peff@peff.net>
Tue, 24 Sep 2024 21:56:34 +0000 (17:56 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Sep 2024 17:24:54 +0000 (10:24 -0700)
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>
t/t5541-http-push-smart.sh
transport-helper.c

index 71428f3d5c760a9bdca7524e15cb9747e92cfd17..3ad514bbd4e303e9c09a311c42847c6baebe3e2d 100755 (executable)
@@ -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"
index c688967b8c817f0b74fc39b2c0d3990dc994b28d..9c8abd8eca4bd88ed6b236130182443a7733c571 100644 (file)
@@ -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;