{"thread":{"id":"14943","subject":"[PATCH] Fix commit_tree() buffer leak","startedAt":"2008-08-11T22:35:11Z","lastAt":"2008-08-11T22:35:11Z","messageCount":1,"participants":["Stephan Beyer"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"86845","messageId":"1218494111-13388-1-git-send-email-s-beyer@gmx.net","threadId":"14943","inReplyTo":null,"subject":"[PATCH] Fix commit_tree() buffer leak","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2008-08-11T22:35:11Z","receivedAt":"2008-08-11T22:35:11Z","isPatch":true,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"The commit_tree() strbuf has a minimum size of 8k and it has not been\nreleased yet.  This patch releases the buffer.\n\nSigned-off-by: Stephan Beyer <s-beyer@gmx.net>\n---\n   Hi,\n\n   I haven't checked if there really is some git command that\n   calls commit_tree() several times, but for the case and for\n   libification's sake this patch seemed useful.\n\n   Regards,\n     Stephan\n\n builtin-commit-tree.c |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-commit-tree.c b/builtin-commit-tree.c\nindex 7a9a309..f773db5 100644\n--- a/builtin-commit-tree.c\n+++ b/builtin-commit-tree.c\n@@ -48,6 +48,7 @@ static const char commit_utf8_warn[] =\n int commit_tree(const char *msg, unsigned char *tree,\n \t\tstruct commit_list *parents, unsigned char *ret)\n {\n+\tint result;\n \tint encoding_is_utf8;\n \tstruct strbuf buffer;\n \n@@ -86,7 +87,9 @@ int commit_tree(const char *msg, unsigned char *tree,\n \tif (encoding_is_utf8 && !is_utf8(buffer.buf))\n \t\tfprintf(stderr, commit_utf8_warn);\n \n-\treturn write_sha1_file(buffer.buf, buffer.len, commit_type, ret);\n+\tresult = write_sha1_file(buffer.buf, buffer.len, commit_type, ret);\n+\tstrbuf_release(&buffer);\n+\treturn result;\n }\n \n int cmd_commit_tree(int argc, const char **argv, const char *prefix)\n-- \n1.6.0.rc2.274.ga7606\n"}]}