git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / 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

* Re: [PATCH] fsck: fix leak when traversing trees
  2018-01-20  7:43 [PATCH] fsck: fix leak when traversing trees Eric Wong
@ 2018-01-23 18:18 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2018-01-23 18:18 UTC (permalink / raw)
  To: Eric Wong; +Cc: git, Jonathan Tan

Eric Wong <e@80x24.org> writes:

> 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")

Yup, we can see that that commit did stop freeing the tree buffer.
Thanks.

>
> 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)

^ permalink raw reply	[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

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).