All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <cwilson@vigilantsw.com>
To: git@vger.kernel.org
Subject: Re: [PATCH] Fix config_file file leak.
Date: Thu, 14 Jul 2011 14:29:19 -0400	[thread overview]
Message-ID: <20110714182919.GB23288@localhost> (raw)
In-Reply-To: <20110714181948.GA23288@localhost>

On Thu, Jul 14, 2011 at 02:19:48PM -0400, Chris Wilson wrote:
> Hi,
> 
> We are using Sentry (a C/C++ static analysis tool) to analyze
> git on a nightly basis. Sentry found that a file leak
> was recently introduced in the commit 924aaf3.
> 
> I'm hoping the attached patch correctly fixes up this leak.

Oops, sorry if I was unclear. This happens in config.c here,
http://git.kernel.org/?p=git/git.git;a=blob;f=config.c;h=1fc063b2562101687b9215e5b697a91fcffdd5bb;hb=924aaf3ef764a5e8e976f68e024ecacf54ff6306
  
This happens once the file is opened successfully here,
  1449         if (!(config_file = fopen(config_filename, "rb"))) {
and then you enter the while loop here,
  1454         while (fgets(buf, sizeof(buf), config_file)) {
and then you take any 'goto out;' in the while loop, which doesn't
close the file handle.

1505  out:
1506         free(config_filename);
1507         return ret;
1508 }


Chris

  reply	other threads:[~2011-07-14 18:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-14 18:19 [PATCH] Fix config_file file leak Chris Wilson
2011-07-14 18:29 ` Chris Wilson [this message]
2011-07-19 17:28 ` Ramsay Jones
2011-07-20 13:12   ` Chris Wilson

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=20110714182919.GB23288@localhost \
    --to=cwilson@vigilantsw.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.