Skip to content

Commit 8c29b49

Browse files
dschogitster
authored andcommitted
range-diff: avoid leaking memory in two error code paths
In the code paths in question, we already release a lot of memory, but the `current_filename` variable was missed. Fix that. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 66e871b commit 8c29b49

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

range-diff.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ static int read_patches(const char *range, struct string_list *list,
9797
if (get_oid(p, &util->oid)) {
9898
error(_("could not parse commit '%s'"), p);
9999
free(util);
100+
free(current_filename);
100101
string_list_clear(list, 1);
101102
strbuf_release(&buf);
102103
strbuf_release(&contents);
@@ -112,6 +113,7 @@ static int read_patches(const char *range, struct string_list *list,
112113
error(_("could not parse first line of `log` output: "
113114
"did not start with 'commit ': '%s'"),
114115
line);
116+
free(current_filename);
115117
string_list_clear(list, 1);
116118
strbuf_release(&buf);
117119
strbuf_release(&contents);

0 commit comments

Comments
 (0)