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

Re: [PATCH] builtin-clone.c: fix memory leak in cmd_clone()

From
ARAli Gholami Rudi <ali@rudi.ir>
Date
Apr 1, 2009, 16:12 UTC
Message-ID
<20090401161254.GD2237@lilem.mirepesht>
In-Reply-To
<alpine.DEB.1.00.0904011754250.13502@intel-tinevez-2-302>
Hi,
Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 10 quoted lines
> On Wed, 1 Apr 2009, Ali Gholami Rudi wrote:
> 
> > With this patch, cmd_clone() safely frees its xstrdup()-allocated
> > memory.  Also junk_work_tree and junk_git_dir (used in remove_junk()
> > which is called asynchronously) were changed to use static arrays rather
> > than sharing the memory allocated in cmd_clone().
> 
> If you want to go down that route, you will have a long way to go: the 
> assumption is pretty much in every cmd_() and main() function that 
> singletons will be free()d automatically when the process ends.

Well... I saw strbuf_release() calls in the end of cmd_clone() and had a quick look at a few other cmd_*() functions; it seems most of them (?) try to free their memory. I thought it might make sense to do that for cmd_clone(). But you're right; they will be freed eventually. (It seems like a minor leak which is respected only some of the times :-) )

Regards, Ali

Previous: Johannes SchindelinNext: Junio C Hamano
Message 3 of 5 in “builtin-clone.c: fix memory leak in cmd_clone()”
  1. builtin-clone.c: fix memory leak in cmd_clone()Ali Gholami Rudi, Apr 1, 2009
  2. Johannes SchindelinApr 1, 2009
  3. Ali Gholami RudiApr 1, 2009
  4. Junio C HamanoApr 1, 2009
  5. Ali Gholami RudiApr 1, 2009

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.