]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sparse-checkout: free string list in write_cone_to_file()
authorJeff King <peff@peff.net>
Tue, 4 Jun 2024 10:13:05 +0000 (06:13 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 Jun 2024 17:38:22 +0000 (10:38 -0700)
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>
builtin/sparse-checkout.c

index 0f52e252493d0d56fd0bcf5a7b9f92a416e86348..8747191484ef50d68fec07e458493ccb834e4db7 100644 (file)
@@ -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)