diff mbox series

[v2,02/27] blame: use "goto cleanup" for cleanup_scoreboard()

Message ID patch-v2-02.27-77e7c2c321e-20220323T203149Z-avarab@gmail.com (mailing list archive)
State Superseded
Headers show
Series revision.[ch]: add and use release_revisions() | expand

Commit Message

Ævar Arnfjörð Bjarmason March 23, 2022, 8:31 p.m. UTC
Amend a freeing pattern added in 0906ac2b54b (blame: use changed-path
Bloom filters, 2020-04-16) to use a "goto cleanup", so that we can be
sure that we call cleanup_scoreboard().

This change is needed so that a subsequent addition of a
release_revisions() doesn't solve this unrelated issue while it's at
it.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/blame.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Junio C Hamano March 24, 2022, 4:23 a.m. UTC | #1
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Amend a freeing pattern added in 0906ac2b54b (blame: use changed-path
> Bloom filters, 2020-04-16) to use a "goto cleanup", so that we can be
> sure that we call cleanup_scoreboard().

Makes sense.

> This change is needed so that a subsequent addition of a
> release_revisions() doesn't solve this unrelated issue while it's at
> it.

Again, this is irrelevant.  This patch alone with or without
anything else is the right fix to plug the leakage of the
scoreboard.

> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  builtin/blame.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/blame.c b/builtin/blame.c
> index 8d15b68afc9..885b381ab83 100644
> --- a/builtin/blame.c
> +++ b/builtin/blame.c
> @@ -1167,7 +1167,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
>  	if (!incremental)
>  		setup_pager();
>  	else
> -		return 0;
> +		goto cleanup;
>  
>  	blame_sort_final(&sb);
>  
> @@ -1201,6 +1201,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
>  		printf("num commits: %d\n", sb.num_commits);
>  	}
>  
> +cleanup:
>  	cleanup_scoreboard(&sb);
>  	return 0;
>  }
diff mbox series

Patch

diff --git a/builtin/blame.c b/builtin/blame.c
index 8d15b68afc9..885b381ab83 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1167,7 +1167,7 @@  int cmd_blame(int argc, const char **argv, const char *prefix)
 	if (!incremental)
 		setup_pager();
 	else
-		return 0;
+		goto cleanup;
 
 	blame_sort_final(&sb);
 
@@ -1201,6 +1201,7 @@  int cmd_blame(int argc, const char **argv, const char *prefix)
 		printf("num commits: %d\n", sb.num_commits);
 	}
 
+cleanup:
 	cleanup_scoreboard(&sb);
 	return 0;
 }