From: Junio C Hamano Date: Thu, 02 Feb 2023 21:55:31 GMT Subject: Re: [PATCH v6 17/19] receive-pack: free() the "ref_name" in "struct command" Message-ID: In-Reply-To: Ævar Arnfjörð Bjarmason writes: > Fix a memory leak that's been with us since this code was introduced > in 575f497456e (Add first cut at "git-receive-pack", 2005-06-29). See > eb1af2df0b1 (git-receive-pack: start parsing ref update commands, > 2005-06-29) for the later change that refactored the code to add the > "ref_name" member. The above description does not really match what the patch does, though. Yes, command.ref_name[] member held varying number of bytes in it, but the code was leaking a singly linked list of the entire command structure, not just ref_name[] member. And the patch makes sure we will release the resource held by the entire chain, not just the ref_name flex-array member.