diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-05-27 13:45:56 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-05-27 20:19:57 +0200 |
commit | 97613b9cb91eb97b8a4df547396465f3184ccdef (patch) | |
tree | eae8b593840d132f8a1bda0bba3d8fb954e002cc /transport.c | |
parent | t: mark a bunch of tests as leak-free (diff) | |
download | git-97613b9cb91eb97b8a4df547396465f3184ccdef.tar.xz git-97613b9cb91eb97b8a4df547396465f3184ccdef.zip |
transport-helper: fix leaking helper name
When initializing the transport helper in `transport_get()`, we
allocate the name of the helper. We neither end up transferring
ownership of the name, nor do we free it. The associated memory thus
leaks.
Fix this memory leak by freeing the string at the calling side in
`transport_get()`. `transport_helper_init()` now creates its own copy of
the string and thus can free it as required.
An alterantive way to fix this would be to transfer ownership of the
string passed into `transport_helper_init()`, which would avoid the call
to xstrdup(1). But it does make for a more surprising calling convention
as we do not typically transfer ownership of strings like this.
Mark now-passing tests as leak free.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r-- | transport.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/transport.c b/transport.c index 0ad04b77fd..83ddea8fbc 100644 --- a/transport.c +++ b/transport.c @@ -1176,6 +1176,7 @@ struct transport *transport_get(struct remote *remote, const char *url) int len = external_specification_len(url); char *handler = xmemdupz(url, len); transport_helper_init(ret, handler); + free(handler); } if (ret->smart_options) { |