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
Junio C Hamano <gitster@pobox.com>
Date
Nov 24, 2008, 03:51 UTC
Message-ID
<7vabbpok6v.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<6bd31bceb3840f14d747972b4858e1c5b215744d.1227227976.git.vmiklos@frugalware.org>
Miklos Vajna <vmiklos@frugalware.org> writes:
Show 16 quoted lines
> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
> ---
>  builtin-clone.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/builtin-clone.c b/builtin-clone.c
> index 8e1a1d3..da21cab 100644
> --- a/builtin-clone.c
> +++ b/builtin-clone.c
> @@ -516,6 +516,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
>  		refs = transport_get_remote_refs(transport);
>  		transport_fetch_refs(transport, refs);
>  	}
> +	free(dir);
>  
>  	clear_extra_refs();

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).

Previous: Miklos VajnaNext: Miklos Vajna
Message 6 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.