fsck: fix leak when traversing trees
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>
Eric Wong committed
Jan 20, 2018 at 07:43 UTC
ba3a08ca0ec0d800d2fdbe73984927c1d8199082
1 file changed
+7
-1
builtin/fsck.c
+7
-1
@@ -170,7 +170,13 @@ static void mark_object_reachable(struct object *obj)
170
171
static int traverse_one_object(struct object *obj)
172
{
173
- return fsck_walk(obj, obj, &fsck_walk_options);
173
+ int result = fsck_walk(obj, obj, &fsck_walk_options);
174
+
175
+ if (obj->type == OBJ_TREE) {
176
+ struct tree *tree = (struct tree *)obj;
177
+ free_tree_buffer(tree);
178
+ }
179
+ return result;
180
}
181
182
static int traverse_reachable(void)