git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] For the sake of correctness, fix file descriptor leak.
@ 2007-11-22  0:59 André Goddard Rosa
  2007-11-25 21:37 ` [Resend Trivial PATCH] " André Goddard Rosa
  0 siblings, 1 reply; 3+ messages in thread
From: André Goddard Rosa @ 2007-11-22  0:59 UTC (permalink / raw)
  To: gitster; +Cc: Git Mailing List

[-- Attachment #1: Type: text/plain, Size: 1131 bytes --]

Hi, all!

    Please cc: me as I'm not subscribed. I'm sending the patch inline
only for review, probably it is mangled.
    Please use the attached patch if you agree with it. Sorry about
sending it attached.

>From 9fba346aca7470633ee46848013051248493896c Mon Sep 17 00:00:00 2001
From: Andre Goddard Rosa <andre.goddard@gmail.com>
Date: Tue, 27 Nov 2007 10:16:22 -0200
Subject: [PATCH] For the sake of correctness, fix file descriptor leak.

Signed-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>
---
 builtin-rerere.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/builtin-rerere.c b/builtin-rerere.c
index 7449323..31766be 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -275,8 +275,10 @@ static int copy_file(const char *src, const char *dest)

 	if (!(in = fopen(src, "r")))
 		return error("Could not open %s", src);
-	if (!(out = fopen(dest, "w")))
+	if (!(out = fopen(dest, "w"))) {
+		fclose(in);
 		return error("Could not open %s", dest);
+	}
 	while ((count = fread(buffer, 1, sizeof(buffer), in)))
 		fwrite(buffer, 1, count, out);
 	fclose(in);
-- 
1.5.3.6.861.gd794-dirty

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-For-the-sake-of-correctness-fix-file-descriptor-le.patch --]
[-- Type: text/x-patch; name=0002-For-the-sake-of-correctness-fix-file-descriptor-le.patch, Size: 921 bytes --]

From 9fba346aca7470633ee46848013051248493896c Mon Sep 17 00:00:00 2001
From: Andre Goddard Rosa <andre.goddard@gmail.com>
Date: Tue, 27 Nov 2007 10:16:22 -0200
Subject: [PATCH] For the sake of correctness, fix file descriptor leak.

Signed-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>
---
 builtin-rerere.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/builtin-rerere.c b/builtin-rerere.c
index 7449323..31766be 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -275,8 +275,10 @@ static int copy_file(const char *src, const char *dest)
 
 	if (!(in = fopen(src, "r")))
 		return error("Could not open %s", src);
-	if (!(out = fopen(dest, "w")))
+	if (!(out = fopen(dest, "w"))) {
+		fclose(in);
 		return error("Could not open %s", dest);
+	}
 	while ((count = fread(buffer, 1, sizeof(buffer), in)))
 		fwrite(buffer, 1, count, out);
 	fclose(in);
-- 
1.5.3.6.861.gd794-dirty


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-11-25 22:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-22  0:59 [PATCH] For the sake of correctness, fix file descriptor leak André Goddard Rosa
2007-11-25 21:37 ` [Resend Trivial PATCH] " André Goddard Rosa
2007-11-25 22:29   ` Junio C Hamano

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