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>

Jinyao Guo committed Jun 13, 2025 at 19:26 UTC ff73f375bbff4b35ef97fb6890de9deaa90924f0
1 file changed +2
mailinfo.c
+2
@@ -266,6 +266,8 @@ static void handle_content_type(struct mailinfo *mi, struct strbuf *line)
266 error("Too many boundaries to handle");
267 mi->input_error = -1;
268 mi->content_top = &mi->content[MAX_BOUNDARIES] - 1;
269 + strbuf_release(boundary);
270 + free(boundary);
271 return;
272 }
273 *(mi->content_top) = boundary;