git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] fsck: fix leak when traversing trees

From
EWEric Wong <e@80x24.org>
Date
Jan 20, 2018, 07:43 UTC
Message-ID
<20180120074351.GA12439@whir>

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
Next: Junio C Hamano
Message 1 of 2 in “fsck: fix leak when traversing trees”
  1. fsck: fix leak when traversing treesEric Wong, Jan 20, 2018
  2. Junio C HamanoJan 23, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.