From: Brad Roberts Date: Sun, 17 Apr 2005 17:55:12 +0000 (-0700) Subject: [PATCH] fix for memory leak in write-tree.c X-Git-Tag: v0.99~849 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=7223a88ce7795f38f47812ebca4433e7f8b82a30;p=git.git [PATCH] fix for memory leak in write-tree.c Fix a memory leak in write-tree.c, not freeing the directory buffer. --- diff --git a/write-tree.c b/write-tree.c index b58871c7..827809db 100644 --- a/write-tree.c +++ b/write-tree.c @@ -93,10 +93,8 @@ static int write_tree(struct cache_entry **cachep, int maxentries, const char *b i -= 5; memcpy(buffer+i, "tree ", 5); - buffer += i; - offset -= i; - - write_sha1_file(buffer, offset, returnsha1); + write_sha1_file(buffer + i, offset - i, returnsha1); + free(buffer); return nr; }