Skip to content

Commit ae3ef94

Browse files
avargitster
authored andcommitted
submodule--helper: fix a memory leak in get_default_remote_submodule()
Fix a memory leak in the get_default_remote_submodule() function added in a77c3fc (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 <[email protected]> Reviewed-by: Glen Choo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 17af0a8 commit ae3ef94

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

builtin/submodule--helper.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,16 @@ static int repo_get_default_remote(struct repository *repo, char **default_remot
6565
static int get_default_remote_submodule(const char *module_path, char **default_remote)
6666
{
6767
struct repository subrepo;
68+
int ret;
6869

6970
if (repo_submodule_init(&subrepo, the_repository, module_path,
7071
null_oid()) < 0)
7172
return die_message(_("could not get a repository handle for submodule '%s'"),
7273
module_path);
73-
return repo_get_default_remote(&subrepo, default_remote);
74+
ret = repo_get_default_remote(&subrepo, default_remote);
75+
repo_clear(&subrepo);
76+
77+
return ret;
7478
}
7579

7680
static char *get_default_remote(void)

0 commit comments

Comments
 (0)