found another resource leak in file xdiff-interface.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]