Git development
 help / color / mirror / Atom feed
From: Ali Gholami Rudi <ali@rudi.ir>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] builtin-clone.c: fix memory leak in cmd_clone()
Date: Wed, 1 Apr 2009 20:42:54 +0430	[thread overview]
Message-ID: <20090401161254.GD2237@lilem.mirepesht> (raw)
In-Reply-To: <alpine.DEB.1.00.0904011754250.13502@intel-tinevez-2-302>

Hi,

Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> 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

  reply	other threads:[~2009-04-01 16:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-01 14:40 [PATCH] builtin-clone.c: fix memory leak in cmd_clone() Ali Gholami Rudi
2009-04-01 15:56 ` Johannes Schindelin
2009-04-01 16:12   ` Ali Gholami Rudi [this message]
2009-04-01 16:23     ` Junio C Hamano
2009-04-01 20:17       ` Ali Gholami Rudi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090401161254.GD2237@lilem.mirepesht \
    --to=ali@rudi.ir \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox