Subject: found another resource leak in file xdiff-interface.c

From: "Martin Ettl" <[email-masked]>
Date: Fri, 10 Jul 2009 09:47:57 +0200

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