* [PATCH] Fix commit_tree() buffer leak
@ 2008-08-11 22:35 Stephan Beyer
0 siblings, 0 replies; only message in thread
From: Stephan Beyer @ 2008-08-11 22:35 UTC (permalink / raw)
To: git; +Cc: Stephan Beyer
The commit_tree() strbuf has a minimum size of 8k and it has not been
released yet. This patch releases the buffer.
Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
---
Hi,
I haven't checked if there really is some git command that
calls commit_tree() several times, but for the case and for
libification's sake this patch seemed useful.
Regards,
Stephan
builtin-commit-tree.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c
index 7a9a309..f773db5 100644
--- a/builtin-commit-tree.c
+++ b/builtin-commit-tree.c
@@ -48,6 +48,7 @@ static const char commit_utf8_warn[] =
int commit_tree(const char *msg, unsigned char *tree,
struct commit_list *parents, unsigned char *ret)
{
+ int result;
int encoding_is_utf8;
struct strbuf buffer;
@@ -86,7 +87,9 @@ int commit_tree(const char *msg, unsigned char *tree,
if (encoding_is_utf8 && !is_utf8(buffer.buf))
fprintf(stderr, commit_utf8_warn);
- return write_sha1_file(buffer.buf, buffer.len, commit_type, ret);
+ result = write_sha1_file(buffer.buf, buffer.len, commit_type, ret);
+ strbuf_release(&buffer);
+ return result;
}
int cmd_commit_tree(int argc, const char **argv, const char *prefix)
--
1.6.0.rc2.274.ga7606
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-08-11 22:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-11 22:35 [PATCH] Fix commit_tree() buffer leak Stephan Beyer
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).