From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] hash-object: prefix_filename() returns allocated memory these days
Date: Wed, 8 Sep 2021 05:42:28 -0400 [thread overview]
Message-ID: <YTiFhNryAxCobH+m@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqsfyg82b5.fsf@gitster.g>
On Tue, Sep 07, 2021 at 03:10:22PM -0700, Junio C Hamano wrote:
> Back when a1be47e4 (hash-object: fix buffer reuse with --path in a
> subdirectory, 2017-03-20) was written, the prefix_filename() helper
> used a static piece of memory to the caller, making the caller
> responsible for copying it, if it wants to keep it across another
> call to the same function. Two callers of the prefix_filename() in
> hash-object were made to xstrdup() the value obtained from it.
>
> But in the same series, when e4da43b1 (prefix_filename: return newly
> allocated string, 2017-03-20) changed the rule to gave the caller
> possession of the memory, we forgot to revert one of the xstrdup()
> changes, allowing the returned value to leak.
Good catch. The patch looks obviously correct to me.
-Peff
prev parent reply other threads:[~2021-09-08 9:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-07 22:10 [PATCH] hash-object: prefix_filename() returns allocated memory these days Junio C Hamano
2021-09-08 9:42 ` Jeff King [this message]
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=YTiFhNryAxCobH+m@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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;
as well as URLs for NNTP newsgroup(s).