Re: [PATCH 09/28] transport-helper: fix strbuf leak in push_refs_with_push()
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Sep 26, 2024, 13:50 UTC
- Message-ID
- <ZvVmllrUvOC3pGJy@pks.im>
- In-Reply-To
- <20240924215634.GI1143820@coredump.intra.peff.net>
On Tue, Sep 24, 2024 at 05:56:34PM -0400, Jeff King wrote:
Show 12 quoted lines
> diff --git a/transport-helper.c b/transport-helper.c
> index c688967b8c..9c8abd8eca 100644
> --- a/transport-helper.c
> +++ b/transport-helper.c
> @@ -1023,6 +1023,7 @@ static int push_refs_with_push(struct transport *transport,
> if (atomic) {
> reject_atomic_push(remote_refs, mirror);
> string_list_clear(&cas_options, 0);
> + strbuf_release(&buf);
> return 0;
> } else
> continue;What's not visible here is that a few lines further down we have another early return where we don't clear `buf`. But that exit is conditioned on `buf.len == 0`, and given that we never `strbuf_reset()` the buffer we know that `buf.len == 0` only when it hasn't ever be allocated.
So this LGTM.
Patrick