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

Re: [PATCH] Fix config_file file leak.

From
CWChris Wilson <cwilson@vigilantsw.com>
Date
Jul 14, 2011, 18:29 UTC
Message-ID
<20110714182919.GB23288@localhost>
In-Reply-To
<20110714181948.GA23288@localhost>
On Thu, Jul 14, 2011 at 02:19:48PM -0400, Chris Wilson wrote:
Show 7 quoted lines
> 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
Previous: Chris WilsonNext: Ramsay Jones
Message 2 of 4 in “Fix config_file file leak.”
  1. Fix config_file file leak.Chris Wilson, Jul 14, 2011
  2. Chris WilsonJul 14, 2011
  3. Ramsay JonesJul 19, 2011
  4. Chris WilsonJul 20, 2011

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.