Subject: Re: Bug report: git -L requires excessive memory.

From: Taylor Blau <[email-masked]>
Date: Mon, 31 Oct 2022 17:56:36 -0400

On Mon, Oct 31, 2022 at 10:45:54PM +0100, SZEDER Gábor wrote:
> 'line-log.c' contains two "NEEDSWORK leaking like a sieve" comments,
> but you managed to stumble upon yet another case (those two are in the
> code path handling merge commits, but your history is linear).

;-).

> The patch below plugs this leak.
>
>   ---  >8  ---
>
> diff --git a/line-log.c b/line-log.c
> index 51d93310a4..b6ea82ac6b 100644
> --- a/line-log.c
> +++ b/line-log.c
> @@ -1195,6 +1195,9 @@ static int process_ranges_ordinary_commit(struct rev_info *rev, struct commit *c
>  	if (parent)
>  		add_line_range(rev, parent, parent_range);
>  	free_line_log_data(parent_range);
> +	for (int i = 0; i < queue.nr; i++)
> +		diff_free_filepair(queue.queue[i]);
> +	free(queue.queue);
>  	return changed;
>  }
>
>   ---  8<  ---

Very nice. I wouldn't be surprised if there are other leaks, in the
line-log code, but fixing one is good regardless. If you resend with
your S-o-b, I'd be happy to queue it.

Thanks,
Taylor