Skip to content

Commit 5c87743

Browse files
committed
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 <[email protected]>
1 parent 2901bbe commit 5c87743

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3724,7 +3724,6 @@ static int apply_patch(int fd, const char *filename, int options)
37243724
struct patch *list = NULL, **listp = &list;
37253725
int skipped_patch = 0;
37263726

3727-
memset(&fn_table, 0, sizeof(struct string_list));
37283727
patch_input_file = filename;
37293728
read_patch_file(&buf, fd);
37303729
offset = 0;
@@ -3791,6 +3790,7 @@ static int apply_patch(int fd, const char *filename, int options)
37913790

37923791
free_patch_list(list);
37933792
strbuf_release(&buf);
3793+
string_list_clear(&fn_table, 0);
37943794
return 0;
37953795
}
37963796

0 commit comments

Comments
 (0)