Re: [PATCH v3 06/26] submodule--helper: fix most "struct pathspec" memory leaks
From: Junio C Hamano <hidden>
Date: 2022-07-21 21:37:15
Ævar Arnfjörð Bjarmason [off-list ref] writes:
quoted hunk
Call clear_pathspec() at the end of various functions that work with and allocate a "struct pathspec". Signed-off-by: Ævar Arnfjörð Bjarmason <redacted> --- 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.