Re: [PATCH v6 17/19] receive-pack: free() the "ref_name" in "struct command"
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 2, 2023, 21:55 UTC
- Message-ID
- <xmqqo7qbspf0.fsf@gitster.g>
- In-Reply-To
- <patch-v6-17.19-4b2db91f5cb-20230202T094704Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 5 quoted lines
> 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.