Re: [PATCH 01/11] Fix memory leak in traverse_commit_list
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 9, 2007, 22:43 UTC
- Message-ID
- <7vmytnqbu2.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <20071109110610.GA19368@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
Show 16 quoted lines
> diff --git a/list-objects.c b/list-objects.c
> index e5c88c2..713bef9 100644
> --- a/list-objects.c
> +++ b/list-objects.c
> @@ -170,4 +170,11 @@ void traverse_commit_list(struct rev_info *revs,
> }
> for (i = 0; i < objects.nr; i++)
> show_object(&objects.objects[i]);
> + free(objects.objects);
> + if (revs->pending.nr) {
> + revs->pending.nr = 0;
> + revs->pending.alloc = 0;
> + revs->pending.objects = NULL;
> + free(revs->pending.objects);
> + }
> }It is locally verifiable that objects.objects are no longer needed after this point, but it made me a bit nervous about freeing of revs->pending.objects.
I think the existing callers are all Ok, but somebody else should double check.