From: Ingo Molnar Date: Thu, 14 Apr 2005 13:12:32 GMT Subject: [patch] git: fix memory leak in write-tree.c Message-ID: <20050414131232.GA21543@elte.hu> In-Reply-To: <20050414120834.GA14290@elte.hu> this patch fixes a memory leak in write-tree.c's write_tree() function - we didnt free the temporary output buffer. Depending on the size of the tree written out this could leak a significant amount of RAM. Ingo Signed-off-by: Ingo Molnar --- write-tree.c.orig +++ write-tree.c @@ -33,12 +33,12 @@ static int write_tree(struct cache_entry { unsigned char subdir_sha1[20]; unsigned long size, offset; - char *buffer; + char *buffer0, *buffer; int i, nr; /* Guess at some random initial size */ size = 8192; - buffer = malloc(size); + buffer0 = buffer = malloc(size); offset = ORIG_OFFSET; nr = 0; @@ -97,6 +97,8 @@ static int write_tree(struct cache_entry offset -= i; write_sha1_file(buffer, offset, returnsha1); + free(buffer0); + return nr; }