summaryrefslogtreecommitdiff
path: root/builtin-tar-tree.c
diff options
context:
space:
mode:
authorRene Scharfe <rene.scharfe@lsrfire.ath.cx>2006-08-04 10:54:08 +0200
committerJunio C Hamano <junkio@cox.net>2006-08-04 02:08:20 -0700
commit7e18e56920bd38ffc1f2c068d943bfd3f012473d (patch)
tree70e975c14abc04400d57214404e4439379af9261 /builtin-tar-tree.c
parentd249b455475977f305240bb73473f25d040012cf (diff)
downloadgit-7e18e56920bd38ffc1f2c068d943bfd3f012473d.tar.gz
git-tar-tree: fix minor memory leak
Free the root tree object buffer when we're done, plugging a minor leak in generate_tar(). Note: we cannot simply free(tree.buf) because this pointer is modified by tree_entry() calls in traverse_tree(). Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-tar-tree.c')
-rw-r--r--builtin-tar-tree.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index 7c48db9ec8..215892b696 100644
--- a/builtin-tar-tree.c
+++ b/builtin-tar-tree.c
@@ -314,6 +314,7 @@ static int generate_tar(int argc, const char **argv, const char *prefix)
struct commit *commit;
struct tree_desc tree;
struct strbuf current_path;
+ void *buffer;
current_path.buf = xmalloc(PATH_MAX);
current_path.alloc = PATH_MAX;
@@ -341,8 +342,8 @@ static int generate_tar(int argc, const char **argv, const char *prefix)
} else
archive_time = time(NULL);
- tree.buf = read_object_with_reference(sha1, tree_type, &tree.size,
- tree_sha1);
+ tree.buf = buffer = read_object_with_reference(sha1, tree_type,
+ &tree.size, tree_sha1);
if (!tree.buf)
die("not a reference to a tag, commit or tree object: %s",
sha1_to_hex(sha1));
@@ -351,6 +352,7 @@ static int generate_tar(int argc, const char **argv, const char *prefix)
write_entry(tree_sha1, &current_path, 040777, NULL, 0);
traverse_tree(&tree, &current_path);
write_trailer();
+ free(buffer);
free(current_path.buf);
return 0;
}