* [PATCH] update-cache --refresh cache entry leak
@ 2005-04-16 22:51 Junio C Hamano
  2005-04-17  3:35 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2005-04-16 22:51 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git
When update-cache --refresh replaces an existing cache entry
with a new one, it forgets to free the original.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
update-cache.c:  61d2b93a751f35ba24f479cd4fc151188916f02a
--- update-cache.c
+++ update-cache.c	2005-04-16 15:49:03.000000000 -0700
@@ -203,6 +203,8 @@
 			printf("%s: needs update\n", ce->name);
 			continue;
 		}
+		if (new != ce)
+			free(ce);
 		active_cache[i] = new;
 	}
 }
^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: [PATCH] update-cache --refresh cache entry leak
  2005-04-16 22:51 [PATCH] update-cache --refresh cache entry leak Junio C Hamano
@ 2005-04-17  3:35 ` Linus Torvalds
  2005-04-17  4:44   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2005-04-17  3:35 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
On Sat, 16 Apr 2005, Junio C Hamano wrote:
>
> When update-cache --refresh replaces an existing cache entry
> with a new one, it forgets to free the original.
I've seen this patch now three times, and it's been wrong every single 
time. Maybe we should add a comment?
That active-cache entry you free()'d was not necessarily allocated with 
malloc(). Most cache-entries are just mmap'ed directly from the index 
file.
Leaking is ok. We cannot leak too much.
		Linus
^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: [PATCH] update-cache --refresh cache entry leak
  2005-04-17  3:35 ` Linus Torvalds
@ 2005-04-17  4:44   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2005-04-17  4:44 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
LT> I've seen this patch now three times, and it's been wrong every single 
LT> time. Maybe we should add a comment?
I found out the previous two just after I sent it out.  Sorry
about that.
^ permalink raw reply	[flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-04-17  4:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-16 22:51 [PATCH] update-cache --refresh cache entry leak Junio C Hamano
2005-04-17  3:35 ` Linus Torvalds
2005-04-17  4:44   ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).