Skip to content

Commit 42c153e

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cdbb720 commit 42c153e

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

remote.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2731,6 +2731,7 @@ static void check_if_includes_upstream(struct ref *remote)
27312731

27322732
if (is_reachable_in_reflog(local->name, remote) <= 0)
27332733
remote->unreachable = 1;
2734+
free_one_ref(local);
27342735
}
27352736

27362737
static void apply_cas(struct push_cas_option *cas,

t/t5533-push-cas.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test_description='compare & swap push force/delete safety'
55
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
66
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
77

8+
TEST_PASSES_SANITIZE_LEAK=true
89
. ./test-lib.sh
910

1011
setup_srcdst_basic () {

0 commit comments

Comments
 (0)