threads / patch / 55

patchupdate-cache --refresh cache entry leak

Subject: [PATCH] update-cache --refresh cache entry leak

## tl;dr

3 messages between Apr 16, 2005 and Apr 17, 2005. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Junio C Hamano· Apr 16, 2005, 22:51 UTC · lore

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
Show changes to diff +2 −0
@@ -203,6 +203,8 @@
 			printf("%s: needs update\n", ce->name);
 			continue;
 		}
+		if (new != ce)
+			free(ce);
 		active_cache[i] = new;
 	}
 }
Linus Torvalds· Apr 17, 2005, 03:35 UTC · re: Junio C Hamano · lore

Re: [PATCH] update-cache --refresh cache entry leak

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
Junio C Hamano· Apr 17, 2005, 04:44 UTC · re: Linus Torvalds · lore

Re: [PATCH] update-cache --refresh cache entry leak

>>>>> "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.

← back to recent threads