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

Re: [PATCH 1/4] builtin-clone: fix a memory leak in cmd_clone()

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Nov 25, 2008, 22:40 UTC
Message-ID
<20081125224005.GG4746@genesis.frugalware.org>
In-Reply-To
<7vabbpok6v.fsf@gitster.siamese.dyndns.org>
On Sun, Nov 23, 2008 at 07:51:36PM -0800, Junio C Hamano <gitster@pobox.com> wrote:
> Can't this be done much earlier?  This variable can potentially be
> assigned to work_tree, but after we set up the atexit handler neither dir
> nor work_tree are not used (it is a bit hard to see as this function
> itself is a bit too big to be maintainable).
Hm, reading the code again I think you should just drop 1/4.

work_tree is a pointer to dir, and junk_work_tree is a pointer to work_tree. junk_work_tree is used in the signal handler, so it has to be allocated during the whole clone.

I guess it was just an accident that my patch passed the tests.
Sorry for the mistake.
Previous: Junio C Hamano
Message 7 of 7 in “builtin-clone: use strbuf”
  1. 0/4 builtin-clone: use strbufMiklos Vajna, Nov 21, 2008
  2. 1/4 builtin-clone: fix a memory leak in cmd_clone()Miklos Vajna, Nov 21, 2008
  3. 2/4 builtin-clone: use strbuf in guess_dir_name()Miklos Vajna, Nov 21, 2008
  4. 3/4 builtin-clone: use strbuf in clone_local() and copy_or_link_directory()Miklos Vajna, Nov 21, 2008
  5. 4/4 builtin_clone: use strbuf in cmd_clone()Miklos Vajna, Nov 21, 2008
  6. Junio C HamanoNov 24, 2008
  7. Miklos VajnaNov 25, 2008

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.