From: Jeff King Date: Fri, 31 May 2024 11:35:45 GMT Subject: [PATCH 10/13] sparse-checkout: free sparse_filename after use Message-ID: <20240531113545.GJ428814@coredump.intra.peff.net> In-Reply-To: <20240531112433.GA428583@coredump.intra.peff.net> 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 --- builtin/sparse-checkout.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index 356b7349f9..3af9fec1fb 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; -- 2.45.1.727.ge984192922