push: free_refs() the "local_refs" in set_refspecs()

Fix a memory leak that's been with us since this code was added in
ca02465b41 (push: use remote.$name.push as a refmap, 2013-12-03).

The "remote = remote_get(...)" added in the same commit would seem to
leak based only on the context here, but that function is a wrapper
for sticking the remotes we fetch into "the_repository->remote_state".

See fd3cb0501e (remote: move static variables into per-repository
struct, 2021-11-17) for the addition of code in repository.c that
free's the "remote" allocated here.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason
2023-02-07 00:07:54 +01:00
committed by Junio C Hamano
parent aa561208d9
commit c65d18cb52
14 changed files with 21 additions and 0 deletions

View File

@ -134,6 +134,7 @@ static void set_refspecs(const char **refs, int nr, const char *repo)
} else
refspec_append(&rs, ref);
}
free_refs(local_refs);
}
static int push_url_of_remote(struct remote *remote, const char ***url_p)