git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* found another resource leak in file xdiff-interface.c
@ 2009-07-10  7:47 Martin Ettl
  0 siblings, 0 replies; only message in thread
From: Martin Ettl @ 2009-07-10  7:47 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-07-10  7:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-10  7:47 found another resource leak in file xdiff-interface.c Martin Ettl

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