From: Jinyao Guo Date: Fri, 13 Jun 2025 19:26:45 +0000 (+0000) Subject: mailinfo.c: fix memory leak in function handle_content_type() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ff73f375bbff4b35ef97fb6890de9deaa90924f0;p=thirdparty%2Fgit.git 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 Signed-off-by: Junio C Hamano --- diff --git a/mailinfo.c b/mailinfo.c index 7b001fa5db..0e9e0e315d 100644 --- a/mailinfo.c +++ b/mailinfo.c @@ -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;