]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/fetch: fix leaking transaction with `--atomic`
authorPatrick Steinhardt <ps@pks.im>
Thu, 22 Aug 2024 09:18:06 +0000 (11:18 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Aug 2024 16:18:06 +0000 (09:18 -0700)
commitc92abe71dfa154d62dc36f1bc7b6c00184c5dbda
tree615357973fd5c2151dada1fa0fcf26f2f64bfd7d
parent8960819e73d266a114f731a5a9a5dd90e5ab38bc
builtin/fetch: fix leaking transaction with `--atomic`

With the `--atomic` flag, we use a single ref transaction to commit all
ref updates in git-fetch(1). The lifetime of transactions is somewhat
weird: while `ref_transaction_abort()` will free the transaction, a call
to `ref_transaction_commit()` won't. We thus have to manually free the
transaction in the successful case.

Adapt the code to free the transaction in the exit path to plug the
resulting memory leak. As `ref_transaction_abort()` already freed the
transaction for us, we have to unset the transaction when we hit that
code path to not cause a double free.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
t/t5574-fetch-output.sh