mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
builtin/log: fix leaking branch name when creating cover letters
When calling `make_cover_letter()` without a branch name, we try to derive the branch name by calling `find_branch_name()`. But while this function returns an allocated string, we never free the result and thus have a memory leak. Fix this. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
34968e56de
commit
7935a02613
@@ -1434,6 +1434,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
|
||||
int need_8bit_cte = 0;
|
||||
struct pretty_print_context pp = {0};
|
||||
struct commit *head = list[0];
|
||||
char *to_free = NULL;
|
||||
|
||||
if (!cmit_fmt_is_mail(rev->commit_format))
|
||||
die(_("cover letter needs email format"));
|
||||
@@ -1455,7 +1456,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
|
||||
}
|
||||
|
||||
if (!branch_name)
|
||||
branch_name = find_branch_name(rev);
|
||||
branch_name = to_free = find_branch_name(rev);
|
||||
|
||||
pp.fmt = CMIT_FMT_EMAIL;
|
||||
pp.date_mode.type = DATE_RFC2822;
|
||||
@@ -1466,6 +1467,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
|
||||
encoding, need_8bit_cte, cfg);
|
||||
fprintf(rev->diffopt.file, "%s\n", sb.buf);
|
||||
|
||||
free(to_free);
|
||||
free(pp.after_subject);
|
||||
strbuf_release(&sb);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user