]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sparse-checkout: free sparse_filename after use
authorJeff King <peff@peff.net>
Tue, 4 Jun 2024 10:13:32 +0000 (06:13 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Jun 2024 16:51:43 +0000 (09:51 -0700)
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>
builtin/sparse-checkout.c

index b84d2e1c800e8432d7a868cbea1e6bbff15d7fd4..79342480eb2ed7ed58908093994d5d24662c6d33 100644 (file)
@@ -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;