Re: [PATCH 03/10] merge: free result of repo_get_merge_bases()
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Oct 5, 2023, 17:42 UTC
- Message-ID
- <ZR71aA4RMoi2TcOJ@nand.local>
- In-Reply-To
- <20231003202724.GC7812@coredump.intra.peff.net>
On Tue, Oct 03, 2023 at 04:27:24PM -0400, Jeff King wrote:
Show 12 quoted lines
> We call repo_get_merge_bases(), which allocates a commit_list, but never > free the result, causing a leak. > > The obvious solution is to free it, but we need to look at the contents > of the first item to decide whether to leave the loop. One option is to > free it in both code paths. But since the commit that the list points to > is longer-lived than the list itself, we can just dereference it > immediately, free the list, and then continue with the existing logic. > This is about the same amount of code, but keeps the list management all > in one place. > > This lets us mark a number of merge-related test scripts as leak-free.
Wow, getting 10 newly leak-free tests for half as many lines of code is terrific. Woohoo!
Thanks, Taylor