aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-09-05 12:09:01 +0200
committerJunio C Hamano <gitster@pobox.com>2024-09-05 08:49:11 -0700
commit42c153e1c06fcfea8446f11bf3fc3bcf9ea25867 (patch)
treec7d73b7c50293414585b1f71434f33d509363053
parentremote: fix leaking tracking refs (diff)
downloadgit-42c153e1c06fcfea8446f11bf3fc3bcf9ea25867.tar.gz
git-42c153e1c06fcfea8446f11bf3fc3bcf9ea25867.zip
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>
-rw-r--r--remote.c1
-rwxr-xr-xt/t5533-push-cas.sh1
2 files changed, 2 insertions, 0 deletions
diff --git a/remote.c b/remote.c
index 8d666c1641..e11b03a075 100644
--- 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,
diff --git a/t/t5533-push-cas.sh b/t/t5533-push-cas.sh
index cba26a872d..6365d99777 100755
--- a/t/t5533-push-cas.sh
+++ b/t/t5533-push-cas.sh
@@ -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 () {