]> git.ipfire.org Git - thirdparty/git.git/commitdiff
remote: fix leak in reachability check of a remote-tracking ref
authorPatrick Steinhardt <ps@pks.im>
Thu, 5 Sep 2024 10:09:01 +0000 (12:09 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Sep 2024 15:49:11 +0000 (08:49 -0700)
In `check_if_includes_upstream()` we retrieve the local ref
corresponding to a remote-tracking ref we want to check reachability
for. We never free that local ref and thus cause a memory leak. Fix
this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c
t/t5533-push-cas.sh

index 8d666c16410fb6f91ce395e561630371610f0621..e11b03a075c3ba69dfa92e29e4986b9db83f9464 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -2731,6 +2731,7 @@ static void check_if_includes_upstream(struct ref *remote)
 
        if (is_reachable_in_reflog(local->name, remote) <= 0)
                remote->unreachable = 1;
+       free_one_ref(local);
 }
 
 static void apply_cas(struct push_cas_option *cas,
index cba26a872dde465c01cd99782029811cf2da9acf..6365d99777ead268ccd589d6990b07fd9c4ec33c 100755 (executable)
@@ -5,6 +5,7 @@ test_description='compare & swap push force/delete safety'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 setup_srcdst_basic () {