From: Martin Schlemmer Date: Thu, 14 Apr 2005 14:25:24 GMT Subject: Re: [patch] git: fix memory leak #2 in read-cache.c Message-ID: <1113488724.23299.106.camel@nosferatu.lan> In-Reply-To: <20050414132550.GA25496@elte.hu> On Thu, 2005-04-14 at 15:25 +0200, Ingo Molnar wrote: > * Ingo Molnar 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