remote: fix leak in reachability check of a remote-tracking ref

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>

Patrick Steinhardt committed Sep 5, 2024 at 12:09 UTC 42c153e1c06fcfea8446f11bf3fc3bcf9ea25867
2 files changed +2
remote.c
+1
@@ -2731,6 +2731,7 @@ static void check_if_includes_upstream(struct ref *remote)
2731
2732 if (is_reachable_in_reflog(local->name, remote) <= 0)
2733 remote->unreachable = 1;
2734 + free_one_ref(local);
2735 }
2736
2737 static void apply_cas(struct push_cas_option *cas,
t/t5533-push-cas.sh
+1
@@ -5,6 +5,7 @@ test_description='compare & swap push force/delete safety'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8 +TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
11 setup_srcdst_basic () {