{"thread":{"id":"47653","subject":"[PATCH] fsck: fix leak when traversing trees","startedAt":"2018-01-20T07:43:57Z","lastAt":"2018-01-23T18:18:32Z","messageCount":2,"participants":["Eric Wong","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"336973","messageId":"20180120074351.GA12439@whir","threadId":"47653","inReplyTo":null,"subject":"[PATCH] fsck: fix leak when traversing trees","fromName":"Eric Wong","fromEmail":"e@80x24.org","sentAt":"2018-01-20T07:43:51Z","receivedAt":"2018-01-20T07:43:57Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"While fsck_walk/fsck_walk_tree/parse_tree populates \"struct tree\"\nidempotently, it is still up to the fsck_walk caller to call\nfree_tree_buffer.\n\nFixes: ad2db4030e42890e (\"fsck: remove redundant parse_tree() invocation\")\n\nSigned-off-by: Eric Wong <e@80x24.org>\n---\n These APIs could probably be made to be less error-prone,\n but at least this stops my little machine from OOM-ing.\n\n builtin/fsck.c | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 04846d46f9..92ce775a74 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -171,7 +171,13 @@ static void mark_object_reachable(struct object *obj)\n \n static int traverse_one_object(struct object *obj)\n {\n-\treturn fsck_walk(obj, obj, &fsck_walk_options);\n+\tint result = fsck_walk(obj, obj, &fsck_walk_options);\n+\n+\tif (obj->type == OBJ_TREE) {\n+\t\tstruct tree *tree = (struct tree *)obj;\n+\t\tfree_tree_buffer(tree);\n+\t}\n+\treturn result;\n }\n \n static int traverse_reachable(void)\n-- \nEW\n"},{"id":"337166","messageId":"xmqqpo60iglr.fsf@gitster.mtv.corp.google.com","threadId":"47653","inReplyTo":"20180120074351.GA12439@whir","subject":"Re: [PATCH] fsck: fix leak when traversing trees","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-01-23T18:18:24Z","receivedAt":"2018-01-23T18:18:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Wong <e@80x24.org> writes:\n\n> While fsck_walk/fsck_walk_tree/parse_tree populates \"struct tree\"\n> idempotently, it is still up to the fsck_walk caller to call\n> free_tree_buffer.\n>\n> Fixes: ad2db4030e42890e (\"fsck: remove redundant parse_tree() invocation\")\n\nYup, we can see that that commit did stop freeing the tree buffer.\nThanks.\n\n>\n> Signed-off-by: Eric Wong <e@80x24.org>\n> ---\n>  These APIs could probably be made to be less error-prone,\n>  but at least this stops my little machine from OOM-ing.\n>\n>  builtin/fsck.c | 8 +++++++-\n>  1 file changed, 7 insertions(+), 1 deletion(-)\n>\n> diff --git a/builtin/fsck.c b/builtin/fsck.c\n> index 04846d46f9..92ce775a74 100644\n> --- a/builtin/fsck.c\n> +++ b/builtin/fsck.c\n> @@ -171,7 +171,13 @@ static void mark_object_reachable(struct object *obj)\n>  \n>  static int traverse_one_object(struct object *obj)\n>  {\n> -\treturn fsck_walk(obj, obj, &fsck_walk_options);\n> +\tint result = fsck_walk(obj, obj, &fsck_walk_options);\n> +\n> +\tif (obj->type == OBJ_TREE) {\n> +\t\tstruct tree *tree = (struct tree *)obj;\n> +\t\tfree_tree_buffer(tree);\n> +\t}\n> +\treturn result;\n>  }\n>  \n>  static int traverse_reachable(void)\n"}]}