From: Eric Sunshine Date: Thu, 23 May 2024 16:59:14 GMT Subject: Re: [PATCH 07/20] diff: refactor code to clarify memory ownership of prefixes Message-ID: In-Reply-To: <18dce492df7d4337dd639be767f2fe280083e9f6.1716465556.git.ps@pks.im> On Thu, May 23, 2024 at 8:26 AM Patrick Steinhardt wrote: > The source end destination prefixes are tracked in a `const char *` s/end/and/ > array, but may at times contain allocated strings. The result is that > those strings may be leaking because we never free them. > > Refactor the code to always store allocated strings in those variables, > freeing them as required. This requires us to handle the default values > a bit different compared to before. But given that there is only a > single callsite where we use the variables to `struct diff_options` it's > easy to handle the defaults there. > > Signed-off-by: Patrick Steinhardt