apply: release memory for fn_table
The fn_table is used to record the result of earlier patch application in case a hand-crafted input file contains multiple patches to the same file. Both its string key (filename) and the contents are borrowed from "struct patch" that represents the previous application in the same apply_patch() call, and they do not leak, but the table itself was not freed properly. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Mar 27, 2012 at 15:14 UTC
5c8774330f5cc7a5e9a4f9e016e06bea6814d8b5
1 file changed
+1
-1
builtin/apply.c
+1
-1
@@ -3724,7 +3724,6 @@ static int apply_patch(int fd, const char *filename, int options)
3724
struct patch *list = NULL, **listp = &list;
3725
int skipped_patch = 0;
3726
3727
- memset(&fn_table, 0, sizeof(struct string_list));
3727
patch_input_file = filename;
3728
read_patch_file(&buf, fd);
3729
offset = 0;
@@ -3791,6 +3790,7 @@ static int apply_patch(int fd, const char *filename, int options)
3790
3791
free_patch_list(list);
3792
strbuf_release(&buf);
3793
+ string_list_clear(&fn_table, 0);
3794
return 0;
3795
}
3796