Skip to content

Commit 1454d73

Browse files
jinyaoguogitster
authored andcommitted
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 1454d73

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mailinfo.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ 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);
271+
boundary = NULL;
269272
return;
270273
}
271274
*(mi->content_top) = boundary;

0 commit comments

Comments
 (0)