diff mbox series

[2/6] grep: use object_array_clear() in cmd_grep()

Message ID patch-2.6-727fdb27a2a-20211021T155529Z-avarab@gmail.com (mailing list archive)
State Superseded
Headers show
Series leaks: miscellaneous small leak fixes | expand

Commit Message

Ævar Arnfjörð Bjarmason Oct. 21, 2021, 3:57 p.m. UTC
Free the "struct object_array" before exiting. This makes grep tests
(e.g.  "t7815-grep-binary.sh") a bit happer under SANITIZE=leak.

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

Comments

Junio C Hamano Oct. 21, 2021, 11:56 p.m. UTC | #1
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Free the "struct object_array" before exiting. This makes grep tests
> (e.g.  "t7815-grep-binary.sh") a bit happer under SANITIZE=leak.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  builtin/grep.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/builtin/grep.c b/builtin/grep.c
> index fd184c182a3..555b2ab6008 100644
> --- a/builtin/grep.c
> +++ b/builtin/grep.c
> @@ -1196,6 +1196,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
>  		run_pager(&opt, prefix);
>  	clear_pathspec(&pathspec);
>  	free_grep_patterns(&opt);
> +	object_array_clear(&list);
>  	free_repos();
>  	return !hit;
>  }

OK.
Junio C Hamano Oct. 21, 2021, 11:58 p.m. UTC | #2
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Free the "struct object_array" before exiting. This makes grep tests
> (e.g.  "t7815-grep-binary.sh") a bit happer under SANITIZE=leak.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  builtin/grep.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/builtin/grep.c b/builtin/grep.c
> index fd184c182a3..555b2ab6008 100644
> --- a/builtin/grep.c
> +++ b/builtin/grep.c
> @@ -1196,6 +1196,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
>  		run_pager(&opt, prefix);
>  	clear_pathspec(&pathspec);
>  	free_grep_patterns(&opt);
> +	object_array_clear(&list);
>  	free_repos();
>  	return !hit;
>  }

Not a new issue introduced by this patch, but after run_pager(), it
seems that opt.output_priv aka path_list is never cleared.  Should
this step do that, too, as the series never revisits this file?
diff mbox series

Patch

diff --git a/builtin/grep.c b/builtin/grep.c
index fd184c182a3..555b2ab6008 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -1196,6 +1196,7 @@  int cmd_grep(int argc, const char **argv, const char *prefix)
 		run_pager(&opt, prefix);
 	clear_pathspec(&pathspec);
 	free_grep_patterns(&opt);
+	object_array_clear(&list);
 	free_repos();
 	return !hit;
 }