[PATCH v3 15/26] submodule--helper: fix a memory leak in get_default_remote_submodule()
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jul 21, 2022, 19:13 UTC
- Message-ID
- <patch-v3-15.26-abfd61f9f05-20220721T191249Z-avarab@gmail.com>
- In-Reply-To
- <cover-v3-00.26-00000000000-20220721T191249Z-avarab@gmail.com>
Fix a memory leak in the get_default_remote_submodule() function added in a77c3fcb5ec (submodule--helper: get remote names from any repository, 2022-03-04), we need to repo_clear() the submodule we initialize.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- builtin/submodule--helper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index a3de17754fd..fe490c8d44d 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -62,9 +62,13 @@ static char *repo_get_default_remote(struct repository *repo) static char *get_default_remote_submodule(const char *module_path) { struct repository subrepo; + char *ret; repo_submodule_init(&subrepo, the_repository, module_path, null_oid()); - return repo_get_default_remote(&subrepo); + ret = repo_get_default_remote(&subrepo); + repo_clear(&subrepo); + + return ret; } static char *get_default_remote(void)
-- 2.37.1.1095.g0bd6f54ba8a