Skip to content

Commit 008f59d

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a14d49c commit 008f59d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

builtin/sparse-checkout.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ static int sparse_checkout_init(int argc, const char **argv, const char *prefix)
500500
return 0;
501501
}
502502

503+
free(sparse_filename);
504+
503505
add_pattern("/*", empty_base, 0, &pl, 0);
504506
add_pattern("!/*/", empty_base, 0, &pl, 0);
505507
pl.use_cone_patterns = init_opts.cone_mode;

0 commit comments

Comments
 (0)