Skip to content

Commit

Permalink
apply: release memory for fn_table
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
gitster committed Mar 27, 2012
1 parent 2901bbe commit 5c87743
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion builtin/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -3724,7 +3724,6 @@ static int apply_patch(int fd, const char *filename, int options)
struct patch *list = NULL, **listp = &list;
int skipped_patch = 0;

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

free_patch_list(list);
strbuf_release(&buf);
string_list_clear(&fn_table, 0);
return 0;
}

Expand Down

0 comments on commit 5c87743

Please sign in to comment.