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>
Junio C Hamano committed
Oct 20, 2015 at 14:32 UTC
12d19e80b049dbedd51e9e6a70260383b9db4dd0
1 file changed
+3
-1
builtin/mailinfo.c
+3
-1
@@ -409,6 +409,8 @@ static int is_rfc2822_header(const struct strbuf *line)
409
410
static int read_one_header_line(struct strbuf *line, FILE *in)
411
{
412
+ struct strbuf continuation = STRBUF_INIT;
413
+
414
/* Get the first part of the line. */
415
if (strbuf_getline(line, in, '\n'))
416
return 0;
@@ -430,7 +432,6 @@ static int read_one_header_line(struct strbuf *line, FILE *in)
432
*/
433
for (;;) {
434
int peek;
433
- struct strbuf continuation = STRBUF_INIT;
435
436
peek = fgetc(in); ungetc(peek, in);
437
if (peek != ' ' && peek != '\t')
@@ -441,6 +442,7 @@ static int read_one_header_line(struct strbuf *line, FILE *in)
442
strbuf_rtrim(&continuation);
443
strbuf_addbuf(line, &continuation);
444
}
445
+ strbuf_release(&continuation);
446
447
return 1;
448
}