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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jun 4, 2024 at 06:13 UTC 2181fe6e464c4a2615db0df1189d1e6fb0575631
1 file changed +2
builtin/sparse-checkout.c
+2
@@ -311,6 +311,8 @@ static void write_cone_to_file(FILE *fp, struct pattern_list *pl)
311 fprintf(fp, "%s/\n", pattern);
312 free(pattern);
313 }
314 +
315 + string_list_clear(&sl, 0);
316 }
317
318 static int write_patterns_and_update(struct pattern_list *pl)