Skip to content

Commit ff73f37

Browse files
jinyaoguogitster
authored andcommitted
mailinfo.c: fix memory leak in function handle_content_type()
The function handle_content_type allocates memory for boundary using xmalloc(sizeof(struct strbuf)). If (++mi->content_top >= &mi->content[MAX_BOUNDARIES]) is true, the function returns without freeing boundary. Signed-off-by: Jinyao Guo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d50a5e8 commit ff73f37

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mailinfo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ static void handle_content_type(struct mailinfo *mi, struct strbuf *line)
266266
error("Too many boundaries to handle");
267267
mi->input_error = -1;
268268
mi->content_top = &mi->content[MAX_BOUNDARIES] - 1;
269+
strbuf_release(boundary);
270+
free(boundary);
269271
return;
270272
}
271273
*(mi->content_top) = boundary;

0 commit comments

Comments
 (0)