summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2018-01-20 07:43:51 +0000
committerJunio C Hamano <gitster@pobox.com>2018-01-23 10:18:37 -0800
commitba3a08ca0ec0d800d2fdbe73984927c1d8199082 (patch)
treef15d26b873b541bbc23bb72d2b3fa8902fc78411
parent78e7b98f452dd8e6c4d88d28532a0a5e98885d59 (diff)
downloadgit-jt/fsck-code-cleanup.tar.gz
fsck: fix leak when traversing treesjt/fsck-code-cleanup
While fsck_walk/fsck_walk_tree/parse_tree populates "struct tree" idempotently, it is still up to the fsck_walk caller to call free_tree_buffer. Fixes: ad2db4030e42890e ("fsck: remove redundant parse_tree() invocation") Signed-off-by: Eric Wong <e@80x24.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/fsck.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 64542ac3de..5aa4a1b336 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -170,7 +170,13 @@ static void mark_object_reachable(struct object *obj)
static int traverse_one_object(struct object *obj)
{
- return fsck_walk(obj, obj, &fsck_walk_options);
+ int result = fsck_walk(obj, obj, &fsck_walk_options);
+
+ if (obj->type == OBJ_TREE) {
+ struct tree *tree = (struct tree *)obj;
+ free_tree_buffer(tree);
+ }
+ return result;
}
static int traverse_reachable(void)