Re: [PATCH v2 11/22] trailer: fix leaking strbufs when formatting trailers
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Nov 5, 2024, 05:54 UTC
- Message-ID
- <ZymzLJ4p7AK_V92K@pks.im>
- In-Reply-To
- <ye7hagpn5xmtlndgk5usx7i4xrg2s32eyukcy6fapxitye24ws@ddrg5zrnxkn3>
On Mon, Nov 04, 2024 at 04:31:34PM -0600, Justin Tobler wrote:
Show 11 quoted lines
> On 24/10/21 11:28AM, Patrick Steinhardt wrote: > > 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.
True, "never" is definitely too strong of a wording here. Will adapt, thanks!
Patrick