git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Ali Gholami Rudi <ali@rudi.ir>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>, git@vger.kernel.org
Subject: Re: [PATCH] builtin-clone.c: fix memory leak in cmd_clone()
Date: Wed, 01 Apr 2009 09:23:04 -0700	[thread overview]
Message-ID: <7v3acs1gyf.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20090401161254.GD2237@lilem.mirepesht> (Ali Gholami Rudi's message of "Wed, 1 Apr 2009 20:42:54 +0430")

Ali Gholami Rudi <ali@rudi.ir> writes:

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

Yup, I'll queue (I won't have time today to work on git it seems) the
other two patches from you, but I was going to drop this one---unless your
plan was to make cmd_clone() callable more than once in order to use it in
say a C rewrite of git submodule or something like that.

  reply	other threads:[~2009-04-01 16:25 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
2009-04-01 16:23     ` Junio C Hamano [this message]
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=7v3acs1gyf.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=ali@rudi.ir \
    --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;
as well as URLs for NNTP newsgroup(s).