Re: [PATCHv3 3/6] line-log.c: fix a memleak
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 31, 2015, 19:03 UTC
- Message-ID
- <xmqqr3s5q9an.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <551A323F.9030305@gmail.com>
Stefan Beller <stefanbeller@gmail.com> writes:
Show 7 quoted lines
> On 30.03.2015 22:06, Junio C Hamano wrote: >> If add-line-range does not take ownership of >> parent_range from us, shouldn't we be freeing it whether we called >> it or not??? > > In my understanding it does take ownership of it. (According to my code > review on friday)
Hmmm.
add_line_range() is given the "parent_range" as its third parameter, i.e. "range".
If there is nothing for the commit yet, it calls line_log_data_copy() on it to make a deep copy and stores that in new, which is then used as the decoration for the commit---the copy is what is retained.
I am not quite sure what the lifetime rule is for the original of this deep copy, i.e. "range", aka "parent_range" of the caller. Who holds pointers into it after this function is done?