]> git.ipfire.org Git - thirdparty/git.git/commit
remote: fix leaking peer ref when expanding refmap
authorPatrick Steinhardt <ps@pks.im>
Thu, 22 Aug 2024 09:18:00 +0000 (11:18 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Aug 2024 16:18:06 +0000 (09:18 -0700)
commit8960819e73d266a114f731a5a9a5dd90e5ab38bc
tree24e01b3925a34946045cae85e77dea530dc2ca55
parent5e9e04a0641a933fd2da62139795ef6fd322835a
remote: fix leaking peer ref when expanding refmap

When expanding remote refs via the refspec in `get_expanded_map()`, we
first copy the remote ref and then override its peer ref with the
expanded name. This may cause a memory leak though in case the peer ref
is already set, as this field is being copied by `copy_ref()`, as well.

Fix the leak by freeing the peer ref before we re-assign the field.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c
t/t5536-fetch-conflicts.sh
t/t5553-set-upstream.sh
t/t5703-upload-pack-ref-in-want.sh
t/t6050-replace.sh