diff mbox series

[09/22] remote: fix leak in reachability check of a remote-tracking ref

Message ID 1446e42f0bab9b31768305283d51b0f6d1df9b48.1724656120.git.ps@pks.im (mailing list archive)
State Superseded
Headers show
Series Memory leak fixes (pt.6) | expand

Commit Message

Patrick Steinhardt Aug. 26, 2024, 7:21 a.m. UTC
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>
---
 remote.c            | 1 +
 t/t5533-push-cas.sh | 1 +
 2 files changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/remote.c b/remote.c
index 240311619ab..bff54046b2c 100644
--- a/remote.c
+++ b/remote.c
@@ -2774,6 +2774,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 cba26a872dd..6365d99777e 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 () {