aboutsummaryrefslogtreecommitdiff
path: root/builtin/mailinfo.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-10-20 14:32:32 -0700
committerJunio C Hamano <gitster@pobox.com>2015-10-21 15:18:50 -0700
commit12d19e80b049dbedd51e9e6a70260383b9db4dd0 (patch)
tree3a8119195e7c26db043f784a76ffb244e21f0b94 /builtin/mailinfo.c
parente38ee06e99635cca0997d6a04f0c22357670090d (diff)
downloadgit-12d19e80b049dbedd51e9e6a70260383b9db4dd0.tar.gz
git-12d19e80b049dbedd51e9e6a70260383b9db4dd0.tar.xz
mailinfo: plug strbuf leak during continuation line handling
Whether this loop is left via EOF/break or upon finding a non-continuation line, the storage used for the contination line handling is left behind. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/mailinfo.c')
-rw-r--r--builtin/mailinfo.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index 73be47c49..a183cd49f 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;
}