]> git.ipfire.org Git - thirdparty/git.git/commit
transport: fix leaking arguments when fetching from bundle
authorPatrick Steinhardt <ps@pks.im>
Thu, 22 Aug 2024 09:18:08 +0000 (11:18 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Aug 2024 16:18:06 +0000 (09:18 -0700)
commit7720460ccf8d5a8fcc5cf37bad97b26d799a5644
tree91d1cd657be3981ace5e338bafa3a690a931487a
parentc92abe71dfa154d62dc36f1bc7b6c00184c5dbda
transport: fix leaking arguments when fetching from bundle

In `fetch_refs_from_bundle()` we assemble a vector of arguments to pass
to `unbundle()`, but never free it. And in theory we wouldn't have to
because `unbundle()` already knows to free the vector for us. But it
fails to do so when it exits early due to `verify_bundle()` failing.

The calling convention that the arguments are freed by the callee and
not the caller feels somewhat weird. Refactor the code such that it is
instead the responsibility of the caller to free the vector, adapting
the only two callsites where we pass extra arguments. This also fixes
the memory leak.

This memory leak gets hit in t5510, but fixing it isn't sufficient to
make the whole test suite pass.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/bundle.c
bundle.c
transport.c