Re: [PATCH] Fix memory leak in function handle_content_type
From: Jinyao Guo <hidden>
Date: 2025-06-13 18:36:44
Subsystem:
the rest · Maintainer:
Linus Torvalds
Hi Kristoffer, Sorry for that. I’m still getting familiar with the Git patch submission workflow and missed the sign-off requirement. I believe the confusion came from using two different Git identities. I’ve now added individual “Signed-off-by” lines for both accounts. From b39b1a8176a344a2fa2c46a6d0ffc27a7bfd9edd Mon Sep 17 00:00:00 2001 From: jinyaoguo <redacted> Date: Thu, 12 Jun 2025 18:48:24 -0400 Subject: [PATCH] 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: Alex Guo <redacted> Signed-off-by: jinyaoguo <redacted> --- mailinfo.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/mailinfo.c b/mailinfo.c
index ee4597da6b..e0ea358311 100644
--- a/mailinfo.c
+++ b/mailinfo.c@@ -266,6 +266,9 @@ 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); + boundary = NULL; return; } *(mi->content_top) = boundary; --
2.34.1 ________________________________________ From: Kristoffer Haugsbakk <redacted> Sent: Friday, June 13, 2025 12:59 To: Josh Soref <redacted>; git@vger.kernel.org <redacted> Cc: Alex <redacted>; Jinyao Guo <redacted> Subject: Re: [PATCH] Fix memory leak in function handle_content_type [You don't often get email from kristofferhaugsbakk@fastmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] ---- External Email: Use caution with attachments, links, or sharing data ---- On Fri, Jun 13, 2025, at 18:52, Alex via GitGitGadget wrote:
From: jinyaoguo <redacted> [snip] Signed-off-by: Alex Guo <redacted>
Like what was said on another patch[1] the From and Signed-off-by names need to match. I didn’t see a resolution to that? If forwarding you need to add your signoff after theirs. [1]: https://lore.kernel.org/git/xmqq1psfxgyv.fsf@gitster.g/ (local) -- Kristoffer Haugsbakk