From: "Martin Ettl" <ettl.martin@gmx.de>
To: git@vger.kernel.org
Subject: found another resource leak in file xdiff-interface.c
Date: Fri, 10 Jul 2009 09:47:57 +0200 [thread overview]
Message-ID: <20090710074757.322180@gmx.net> (raw)
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
reply other threads:[~2009-07-10 7:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090710074757.322180@gmx.net \
--to=ettl.martin@gmx.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.