diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index 73be47c497..a183cd49fd 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -409,6 +409,8 @@ static int is_rfc2822_header(const struct strbuf *line) static int read_one_header_line(struct strbuf *line, FILE *in) { + struct strbuf continuation = STRBUF_INIT; + /* Get the first part of the line. */ if (strbuf_getline(line, in, '\n')) return 0; @@ -430,7 +432,6 @@ static int read_one_header_line(struct strbuf *line, FILE *in) */ for (;;) { int peek; - struct strbuf continuation = STRBUF_INIT; peek = fgetc(in); ungetc(peek, in); if (peek != ' ' && peek != '\t') @@ -441,6 +442,7 @@ static int read_one_header_line(struct strbuf *line, FILE *in) strbuf_rtrim(&continuation); strbuf_addbuf(line, &continuation); } + strbuf_release(&continuation); return 1; }