git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fsck: fix leak when traversing trees
@ 2018-01-20  7:43 Eric Wong
  2018-01-23 18:18 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2018-01-20  7:43 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Jonathan Tan

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>
---
 These APIs could probably be made to be less error-prone,
 but at least this stops my little machine from OOM-ing.

 builtin/fsck.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index 04846d46f9..92ce775a74 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -171,7 +171,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)
-- 
EW

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-23 18:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-20  7:43 [PATCH] fsck: fix leak when traversing trees Eric Wong
2018-01-23 18:18 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).