# [PATCH] mktree: fix a memory leak in write_tree()

1 messages from 2011-11-11 to 2011-11-11. Participants: Liu Yuan.
Thread: https://gitlist.dev/t/28910

## Liu Yuan, 2011-11-11 03:51

Subject: [PATCH] mktree: fix a memory leak in write_tree()
Message-ID: <1320983471-3165-1-git-send-email-namei.unix@gmail.com>
URL: https://gitlist.dev/e/1320983471-3165-1-git-send-email-namei.unix%40gmail.com

```
From: Liu Yuan <tailai.ly@taobao.com>

We forget to call strbuf_release to release the buf memory.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
---
 builtin/mktree.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/builtin/mktree.c b/builtin/mktree.c
index 098395f..4ae1c41 100644
--- a/builtin/mktree.c
+++ b/builtin/mktree.c
@@ -60,6 +60,7 @@ static void write_tree(unsigned char *sha1)
 	}
 
 	write_sha1_file(buf.buf, buf.len, tree_type, sha1);
+	strbuf_release(&buf);
 }
 
 static const char *mktree_usage[] = {
-- 
1.7.6.1

```
