Re: [PATCH v2 11/22] trailer: fix leaking strbufs when formatting trailers
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Nov 4, 2024, 22:31 UTC
- Message-ID
- <ye7hagpn5xmtlndgk5usx7i4xrg2s32eyukcy6fapxitye24ws@ddrg5zrnxkn3>
- In-Reply-To
- <5b851453bcea945f95c3f29138e510d8448e96e6.1729502824.git.ps@pks.im>
On 24/10/21 11:28AM, Patrick Steinhardt wrote:
Show 5 quoted lines
> We are populating, but never releasing two string buffers in > `format_trailers()`, causing a memory leak. Plug this leak by lifting > those buffers outside of the loop and releasing them on function return. > This fixes the memory leaks, but also optimizes the loop as we don't > have to reallocate the buffers on every single iteration.
I see that we were previously calling `strbuf_release()` inside of the loop. In practice were these never hit? Or just sometimes skipped my the "continue" in the loop? The commit message makes it sound like the former.