]> git.ipfire.org Git - thirdparty/git.git/commit
sparse-checkout: free pattern list in sparse_checkout_list()
authorJeff King <peff@peff.net>
Tue, 4 Jun 2024 10:13:35 +0000 (06:13 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Jun 2024 16:51:43 +0000 (09:51 -0700)
commit521e04e6e8d234e89a5bbeac0b432724b98ac508
tree90177e72ffee38194c75a22ce9bb278015126a24
parent008f59d2d6b3be1017d8d321985b89d85659df04
sparse-checkout: free pattern list in sparse_checkout_list()

In sparse_checkout_list(), we create a pattern_list that needs to
eventually be cleared. We remember to do so in the regular code path,
but the cone-mode path does an early return, and forgets to clean up.

We could fix the leak by adding a new call to clear_pattern_list(). But
we can simplify even further by just skipping the early return, pushing
the other code path (which consists now of only one line!) into an else
block. That also matches the same cone/non-cone if/else used in some
other functions.

This fixes 15 leaks found in t1091.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/sparse-checkout.c