From: Jeff King Date: Tue, 4 Jun 2024 10:13:05 +0000 (-0400) Subject: sparse-checkout: free string list in write_cone_to_file() X-Git-Tag: v2.46.0-rc0~62^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2181fe6e464c4a2615db0df1189d1e6fb0575631;p=thirdparty%2Fgit.git sparse-checkout: free string list in write_cone_to_file() We use a string list to hold sorted and de-duped patterns, but don't free it before leaving the function, causing a leak. This drops the number of leaks found in t7002 from 27 to 25. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index 0f52e25249..8747191484 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -311,6 +311,8 @@ static void write_cone_to_file(FILE *fp, struct pattern_list *pl) fprintf(fp, "%s/\n", pattern); free(pattern); } + + string_list_clear(&sl, 0); } static int write_patterns_and_update(struct pattern_list *pl)