diff options
| author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2022-09-01 01:14:17 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-09-02 09:18:13 -0700 |
| commit | ae3ef94d9bc61931636647c4eab558e09aaeb50a (patch) | |
| tree | 117246f3475645e8fbd254abe7ee5603a440568a /builtin/submodule--helper.c | |
| parent | 17af0a8444523f4df98e21165a3e476f05749237 (diff) | |
| download | git-ae3ef94d9bc61931636647c4eab558e09aaeb50a.tar.gz | |
submodule--helper: fix a memory leak in get_default_remote_submodule()
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>
Reviewed-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/submodule--helper.c')
| -rw-r--r-- | builtin/submodule--helper.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 79ffcb5090..8866af2250 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -65,12 +65,16 @@ static int repo_get_default_remote(struct repository *repo, char **default_remot static int get_default_remote_submodule(const char *module_path, char **default_remote) { struct repository subrepo; + int ret; if (repo_submodule_init(&subrepo, the_repository, module_path, null_oid()) < 0) return die_message(_("could not get a repository handle for submodule '%s'"), module_path); - return repo_get_default_remote(&subrepo, default_remote); + ret = repo_get_default_remote(&subrepo, default_remote); + repo_clear(&subrepo); + + return ret; } static char *get_default_remote(void) |
