]> git.ipfire.org Git - thirdparty/git.git/commit
transport-helper: fix leaking helper name
authorPatrick Steinhardt <ps@pks.im>
Mon, 27 May 2024 11:45:56 +0000 (13:45 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 May 2024 18:19:57 +0000 (11:19 -0700)
commit97613b9cb91eb97b8a4df547396465f3184ccdef
treeeae8b593840d132f8a1bda0bba3d8fb954e002cc
parentfba95dad6ad83fd27eaf57cf526110faa8a20833
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>
t/t0611-reftable-httpd.sh
t/t5563-simple-http-auth.sh
t/t5564-http-proxy.sh
t/t5581-http-curl-verbose.sh
transport-helper.c
transport.c