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

found another resource leak in file xdiff-interface.c

From
MEMartin Ettl <ettl.martin@gmx.de>
Date
Jul 10, 2009, 07:47 UTC
Message-ID
<20090710074757.322180@gmx.net>
Hi friends,
i have detected another resource leak (using the static code analysis tool cppcheck) in file xdiff-interface.c.
The tool prints the following warning:
[git.1.6.3.3/xdiff-interface.c:215](error) resource leak f
int read_mmfile(mmfile_t *ptr, const char *filename)
{
//...
	if (sz && fread(ptr->ptr, sz, 1, f) != 1)
		return error("Could not read %s", filename);
	fclose(f);
// ....
	ptr->size = sz;
	return 0;
}
A possible solution might be:
int read_mmfile(mmfile_t *ptr, const char *filename)
{
//...
	if (sz && fread(ptr->ptr, sz, 1, f) != 1)
        {
	        fclose(f);
		return error("Could not read %s", filename);
        }
	fclose(f);
// ....
	ptr->size = sz;
	return 0;
}
Best regards
Ettl Martin
-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
Message 1 of 1 in “found another resource leak in file xdiff-interface.c”
  1. Martin EttlJul 10, 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.