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

Re: [PATCH] hash-object: prefix_filename() returns allocated memory these days

From
Jeff King <peff@peff.net>
Date
Sep 8, 2021, 09:42 UTC
Message-ID
<YTiFhNryAxCobH+m@coredump.intra.peff.net>
In-Reply-To
<xmqqsfyg82b5.fsf@gitster.g>
On Tue, Sep 07, 2021 at 03:10:22PM -0700, Junio C Hamano wrote:
Show 11 quoted lines
> 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
Previous: Junio C Hamano
Message 2 of 2 in “hash-object: prefix_filename() returns allocated memory these days”
  1. hash-object: prefix_filename() returns allocated memory these daysJunio C Hamano, Sep 7, 2021
  2. Jeff KingSep 8, 2021

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.