aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/sparse-checkout.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2024-06-04 06:13:32 -0400
committerJunio C Hamano <gitster@pobox.com>2024-06-05 09:51:43 -0700
commit008f59d2d6b3be1017d8d321985b89d85659df04 (patch)
treeacf241fb9e1739d2066155f366c08fb88f1fea84 /builtin/sparse-checkout.c
parentsparse-checkout: refactor temporary sparse_checkout_patterns (diff)
downloadgit-008f59d2d6b3be1017d8d321985b89d85659df04.tar.gz
git-008f59d2d6b3be1017d8d321985b89d85659df04.zip
sparse-checkout: free sparse_filename after use
We allocate a heap buffer via get_sparse_checkout_filename(). Most calls remember to free it, but sparse_checkout_init() forgets to, causing a leak. Ironically, it remembers to do so in the error return paths, but not in the path that makes it all the way to the function end! Fixing this clears up 6 leaks from t1091. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/sparse-checkout.c')
-rw-r--r--builtin/sparse-checkout.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index b84d2e1c80..79342480eb 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -500,6 +500,8 @@ static int sparse_checkout_init(int argc, const char **argv, const char *prefix)
return 0;
}
+ free(sparse_filename);
+
add_pattern("/*", empty_base, 0, &pl, 0);
add_pattern("!/*/", empty_base, 0, &pl, 0);
pl.use_cone_patterns = init_opts.cone_mode;