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 <guo846@purdue.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Jinyao Guo 2025-06-13 19:26:45 +00:00 committed by Junio C Hamano
parent d50a5e8939
commit ff73f375bb
1 changed files with 2 additions and 0 deletions

View File

@ -266,6 +266,8 @@ static void handle_content_type(struct mailinfo *mi, struct strbuf *line)
error("Too many boundaries to handle");
mi->input_error = -1;
mi->content_top = &mi->content[MAX_BOUNDARIES] - 1;
strbuf_release(boundary);
free(boundary);
return;
}
*(mi->content_top) = boundary;