@matheusbsbs / matheus-bagliano / commits / ffa9fd9570
Fork 0

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>

Stephan Beyer committed Aug 12, 2008 at 00:35 UTC ffa9fd957039902c9a08946d82ccb729a34ed68b
1 file changed +4 -1
builtin-commit-tree.c
+4 -1
@@ -48,6 +48,7 @@ static const char commit_utf8_warn[] =
48 int commit_tree(const char *msg, unsigned char *tree,
49 struct commit_list *parents, unsigned char *ret)
50 {
51 + int result;
52 int encoding_is_utf8;
53 struct strbuf buffer;
54
@@ -86,7 +87,9 @@ int commit_tree(const char *msg, unsigned char *tree,
87 if (encoding_is_utf8 && !is_utf8(buffer.buf))
88 fprintf(stderr, commit_utf8_warn);
89
89 - return write_sha1_file(buffer.buf, buffer.len, commit_type, ret);
90 + result = write_sha1_file(buffer.buf, buffer.len, commit_type, ret);
91 + strbuf_release(&buffer);
92 + return result;
93 }
94
95 int cmd_commit_tree(int argc, const char **argv, const char *prefix)