git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Fix memory leak in function handle_content_type

From
Jinyao Guo <guo846@purdue.edu>
Date
Jun 13, 2025, 19:26 UTC
Message-ID
<SA1PR22MB399911638F342E1AA20F014AE477A@SA1PR22MB3999.namprd22.prod.outlook.com>
In-Reply-To
<xmqq7c1f8nr2.fsf@gitster.g>
Sure. I'll choose one account and use it consistently.
Here is the edited patch:
From 04b286cb2e736c3a53287b6ddf406e704f19fb2e Mon Sep 17 00:00:00 2001
From: jinyaoguo <guo846@purdue.edu>
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: jinyaoguo <guo846@purdue.edu>
---
 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 


Best,
Jinyao
________________________________________
From: Junio C Hamano <gitster@pobox.com>
Sent: Friday, June 13, 2025 15:06
To: Jinyao Guo <guo846@purdue.edu>
Cc: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>; Josh Soref <gitgitgadget@gmail.com>; git@vger.kernel.org <git@vger.kernel.org>; Alex <alexguo1023@gmail.com>
Subject: Re: [PATCH] Fix memory leak in function handle_content_type
 
---- External Email: Use caution with attachments, links, or sharing data ----


Jinyao Guo <guo846@purdue.edu> writes:

> ... I believe
> the confusion came from using two different Git identities.  I’ve
> now added individual “Signed-off-by” lines for both accounts.

Please do not do this, if these two are the same single person.

Instead, pick the one you want to be known as to this community, and
use that consistently while working on this project.

Thanks.
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 8 in “Fix memory leak in function handle_content_type”
  1. Fix memory leak in function handle_content_typeAlex via GitGitGadget, Jun 13, 2025
  2. Kristoffer HaugsbakkJun 13, 2025
  3. Jinyao GuoJun 13, 2025
  4. Junio C HamanoJun 13, 2025
  5. Jinyao GuoJun 13, 2025
  6. Junio C HamanoJun 14, 2025
  7. Lidong YanJun 15, 2025
  8. Junio C HamanoJun 16, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.