git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Papp <djszapi2@gmail.com>
To: git@vger.kernel.org
Cc: Laszlo Papp <djszapi@archlinux.us>
Subject: [PATCH] Fix resource leaks in wrapper.c
Date: Tue, 27 Oct 2009 04:53:55 +0100	[thread overview]
Message-ID: <1256615635-4940-1-git-send-email-djszapi@archlinux.us> (raw)

Fix the following issues with the desired close tags:

[wrapper.c:276]: (error) Resource leak: fd
[wrapper.c:291]: (error) Resource leak: fd

Signed-off-by: Laszlo Papp <djszapi@archlinux.us>
---
 wrapper.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/wrapper.c b/wrapper.c
index c9be140..76ecf0a 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -266,7 +266,7 @@ int odb_mkstemp(char *template, size_t limit, const char *pattern)
 	fd = mkstemp(template);
 	if (0 <= fd)
 		return fd;
-
+	close(fd);
 	/* slow path */
 	/* some mkstemp implementations erase template on failure */
 	snprintf(template, limit, "%s/%s",
@@ -284,7 +284,7 @@ int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1)
 	fd = open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
 	if (0 <= fd)
 		return fd;
-
+	close(fd);
 	/* slow path */
 	safe_create_leading_directories(name);
 	return open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
-- 
1.6.5

             reply	other threads:[~2009-10-27  3:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-27  3:53 Laszlo Papp [this message]
2009-10-27  7:13 ` [PATCH] Fix resource leaks in wrapper.c Johannes Sixt
2009-10-27  8:26   ` Michael J Gruber
     [not found]     ` <a362e8010910270335g106024e6if3f016c271ab55d6@mail.gmail.com>
2009-10-27 11:44       ` Michael J Gruber

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=1256615635-4940-1-git-send-email-djszapi@archlinux.us \
    --to=djszapi2@gmail.com \
    --cc=djszapi@archlinux.us \
    --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 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).