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>
This commit is contained in:
Patrick Steinhardt
2024-09-05 12:09:01 +02:00
committed by Junio C Hamano
parent cdbb7208c8
commit 42c153e1c0
2 changed files with 2 additions and 0 deletions

View File

@ -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,

View File

@ -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 () {