From: Junio C Hamano <gitster@pobox.com>
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
Date: Sat, 14 Jun 2025 09:45:46 -0700 [thread overview]
Message-ID: <xmqq1prm6zlx.fsf@gitster.g> (raw)
In-Reply-To: <SA1PR22MB399911638F342E1AA20F014AE477A@SA1PR22MB3999.namprd22.prod.outlook.com> (Jinyao Guo's message of "Fri, 13 Jun 2025 19:26:45 +0000")
Jinyao Guo <guo846@purdue.edu> writes:
> @@ -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;
"boundary" is a on-stack local variable. There is no need to assign
NULL to it immediately before you return. In the post-context of
this hunk, we free it but leave the variable pointing at a random
place after that before returning.
next prev parent reply other threads:[~2025-06-14 16:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-13 16:52 [PATCH] Fix memory leak in function handle_content_type Alex via GitGitGadget
2025-06-13 16:59 ` Kristoffer Haugsbakk
2025-06-13 18:36 ` Jinyao Guo
2025-06-13 19:06 ` Junio C Hamano
2025-06-13 19:26 ` Jinyao Guo
2025-06-14 16:45 ` Junio C Hamano [this message]
2025-06-15 12:55 ` Lidong Yan
2025-06-16 1:01 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq1prm6zlx.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=alexguo1023@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=guo846@purdue.edu \
--cc=kristofferhaugsbakk@fastmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox