Skip to content

Commit 12d19e8

Browse files
committed
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 <[email protected]>
1 parent e38ee06 commit 12d19e8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

builtin/mailinfo.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ static int is_rfc2822_header(const struct strbuf *line)
409409

410410
static int read_one_header_line(struct strbuf *line, FILE *in)
411411
{
412+
struct strbuf continuation = STRBUF_INIT;
413+
412414
/* Get the first part of the line. */
413415
if (strbuf_getline(line, in, '\n'))
414416
return 0;
@@ -430,7 +432,6 @@ static int read_one_header_line(struct strbuf *line, FILE *in)
430432
*/
431433
for (;;) {
432434
int peek;
433-
struct strbuf continuation = STRBUF_INIT;
434435

435436
peek = fgetc(in); ungetc(peek, in);
436437
if (peek != ' ' && peek != '\t')
@@ -441,6 +442,7 @@ static int read_one_header_line(struct strbuf *line, FILE *in)
441442
strbuf_rtrim(&continuation);
442443
strbuf_addbuf(line, &continuation);
443444
}
445+
strbuf_release(&continuation);
444446

445447
return 1;
446448
}

0 commit comments

Comments
 (0)