git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 18:11 UTC

Re: [PATCH] http: fix memory leak in fetch_and_setup_pack_index()

From
Jeff King <peff@peff.net>
Date
May 29, 2026, 05:32 UTC
Message-ID
<20260529053245.GB1099450@coredump.intra.peff.net>
In-Reply-To
<aheY6bLM2gxtMDdr@lorenzo-VM>
On Thu, May 28, 2026 at 03:22:49AM +0200, Lorenzo Pegorari wrote:
Show 21 quoted lines
> > So I _think_ we could get away with dropping the existing unlink() call
> > and just let it get cleaned up at process exit. But if we are going to
> > keep it, do we want to also unlink() in this error path? At which point
> > it might make more sense to have an "out" label to consolidate all of
> > this cleanup.
> > 
> > If we are going to unlink() here it may also make sense to just return
> > the tempfile struct from fetch_pack_index(), and then we can call
> > delete_tempfile() on it. See the in-code comment in 63aca3f7f1 which
> > mentions this hackery.
> > 
> > So I dunno. I think your patch is doing the right thing as-is, but it
> > may be worth taking a moment to clean this up a bit further.
> 
> The `unlink()` indeed is weird. Pointing me to the commit 63aca3f7f1
> really helped me understand how the code changed and the current
> situation. Thanks a lot for that.
> 
> I've tried testing as thoroughly as possible whether removing the
> `unlink()` function call wouldn't change the expected behavior.
> *I think* that it can be removed safely, but I'm not 100% sure yet.

I think the only behavior difference in removing the unlink() is whether we immediately delete the downloaded packfile on error, or if we wait until process exit. From the perspective of somebody calling git-fetch, the outcome is roughly the same (when the process ends, the file is gone). It would only differ if the system crashed before the process ended.

-Peff
Previous: LorenzoPegorariNext: Jeff King
Message 5 of 13 in “http: fix memory leak in fetch_and_setup_pack_index()”
  1. http: fix memory leak in fetch_and_setup_pack_index()LorenzoPegorari, May 19, 2026
  2. Jeff KingMay 19, 2026
  3. Lorenzo PegorariMay 28, 2026
  4. http: fix memory leak in fetch_and_setup_pack_index()LorenzoPegorari, May 28, 2026
  5. Jeff KingMay 29, 2026
  6. Jeff KingMay 29, 2026
  7. Jeff KingMay 29, 2026
  8. Lorenzo PegorariJun 1, 2026
  9. Lorenzo PegorariJun 1, 2026
  10. 0/2 http: fix memory leak in fetch_and_setup_pack_index()LorenzoPegorari, Jun 1, 2026
  11. 1/2 http: cleanup function fetch_and_setup_pack_index()LorenzoPegorari, Jun 1, 2026
  12. 2/2 http: fix memory leak in fetch_and_setup_pack_index()LorenzoPegorari, Jun 1, 2026
  13. Jeff KingJun 2, 2026

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.