From: Jim Meyering <jim@meyering•net>
To: git list <git@vger•kernel.org>
Subject: [PATCH] transport-helper.c: don't leak fdopen'd stream buffers
Date: Sat, 12 Sep 2009 11:38:58 +0200 [thread overview]
Message-ID: <87hbv833kd.fsf@meyering.net> (raw)
Looking in the vicinity today, I noticed that these
fdopen'd streams were never fclosed; technically a leak
of both the FILE buffer and the file descriptor.
>From aeae4edb1146b107f6a397118db8b0ac06b884d9 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat•com>
Date: Sat, 12 Sep 2009 11:35:17 +0200
Subject: [PATCH] transport-helper.c: don't leak fdopen'd stream buffers
* transport-helper.c (get_helper, fetch_with_fetch, get_refs_list):
Call fclose on each just-created FILE* pointer, when done.
Signed-off-by: Jim Meyering <meyering@redhat•com>
---
transport-helper.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/transport-helper.c b/transport-helper.c
index f57e84c..0bbd014 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -49,6 +49,7 @@ static struct child_process *get_helper(struct transport *transport)
if (!strcmp(buf.buf, "fetch"))
data->fetch = 1;
}
+ fclose (file);
return data->helper;
}
@@ -88,6 +89,7 @@ static int fetch_with_fetch(struct transport *transport,
if (strbuf_getline(&buf, file, '\n') == EOF)
exit(128); /* child died, message supplied already */
}
+ fclose (file);
return 0;
}
@@ -147,6 +149,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
get_sha1_hex(buf.buf, (*tail)->old_sha1);
tail = &((*tail)->next);
}
+ fclose (file);
strbuf_release(&buf);
for (posn = ret; posn; posn = posn->next)
--
1.6.5.rc0.190.g15871
next reply other threads:[~2009-09-12 9:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-12 9:38 Jim Meyering [this message]
2009-09-13 2:27 ` [PATCH] transport-helper.c: don't leak fdopen'd stream buffers Junio C Hamano
2009-09-13 7:45 ` Jim Meyering
2009-09-13 15:20 ` Johannes Sixt
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=87hbv833kd.fsf@meyering.net \
--to=jim@meyering$(echo .)net \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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