aboutsummaryrefslogtreecommitdiff
path: root/builtin-commit-tree.c
diff options
context:
space:
mode:
authorStephan Beyer <s-beyer@gmx.net>2008-08-12 00:35:11 +0200
committerJunio C Hamano <gitster@pobox.com>2008-08-17 16:27:17 -0700
commitffa9fd957039902c9a08946d82ccb729a34ed68b (patch)
tree192ccf7f7047382bb89e36b12eccec8bdbc4f6ee /builtin-commit-tree.c
parent2ebc02d32a4360da2cf69c2b5f5bfad0716d42b0 (diff)
downloadgit-ffa9fd957039902c9a08946d82ccb729a34ed68b.tar.gz
git-ffa9fd957039902c9a08946d82ccb729a34ed68b.tar.xz
Fix commit_tree() buffer leak
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-commit-tree.c')
-rw-r--r--builtin-commit-tree.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c
index 7a9a309be..f773db596 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)