Re: [PATCH v3 06/26] submodule--helper: fix most "struct pathspec" memory leaks
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 21, 2022, 21:37 UTC
- Message-ID
- <xmqqr12edu65.fsf@gitster.g>
- In-Reply-To
- <patch-v3-06.26-7672ef1305f-20220721T191249Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 26 quoted lines
> Call clear_pathspec() at the end of various functions that work with
> and allocate a "struct pathspec".
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
> builtin/submodule--helper.c | 84 +++++++++++++++++++++++++------------
> 1 file changed, 58 insertions(+), 26 deletions(-)
>
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index 73ac1fcbb9c..a60dc6af178 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -269,7 +269,7 @@ static char *get_up_path(const char *path)
> static int module_list(int argc, const char **argv, const char *prefix)
> {
> int i;
> - struct pathspec pathspec;
> + struct pathspec pathspec = { 0 };
> struct module_list list = MODULE_LIST_INIT;
>
> struct option module_list_options[] = {
> @@ -278,6 +278,7 @@ static int module_list(int argc, const char **argv, const char *prefix)
> N_("alternative anchor for relative paths")),
> OPT_END()
> };
> + int ret = 1;Move this way above, perhaps next to where "int i;" is declared, or replace the blank before where module_list_options[] is declared with this line.
The same comment applies to changes to module_foreach() and status_submodule_cb() in this patch. The change to absorb_git_dirs() gets it right.
Thanks.