Re: [patch] git: fix memory leak #2 in read-cache.c
On Thu, 2005-04-14 at 15:25 +0200, Ingo Molnar wrote:
Show 18 quoted lines
> * Ingo Molnar <mingo@elte.hu> wrote:
>
> > this patch fixes a memory leak in read-cache.c: when there's cache
> > entry collision we should free the previous one.
>
> > + free(active_cache[pos]);
> > active_cache[pos] = ce;
>
> i'm having second thoughs about this one: active_cache entries are not
> always malloc()-ed - e.g. read_cache() will construct them from the
> mmap() of the index file. Which must not be free()d!
>
> one safe solution would be to malloc() all these entries and copy them
> over from the index file? Slightly slower but safer and free()-able when
> update-cache.c notices a collision. The (tested) patch below does this.
>
> this would also make Martin Schlemmer's update-cache.c fix safe.
>
Ok, bad me it seems - assumed it was malloc'd.
--
Martin Schlemmer