{"thread":{"id":"55","subject":"[PATCH] update-cache --refresh cache entry leak","startedAt":"2005-04-16T22:51:46Z","lastAt":"2005-04-17T04:44:46Z","messageCount":3,"participants":["Junio C Hamano","Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"369","messageId":"7v8y3i5o8t.fsf@assigned-by-dhcp.cox.net","threadId":"55","inReplyTo":null,"subject":"[PATCH] update-cache --refresh cache entry leak","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-16T22:51:46Z","receivedAt":"2005-04-16T22:51:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When update-cache --refresh replaces an existing cache entry\nwith a new one, it forgets to free the original.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\nupdate-cache.c:  61d2b93a751f35ba24f479cd4fc151188916f02a\n--- update-cache.c\n+++ update-cache.c\t2005-04-16 15:49:03.000000000 -0700\n@@ -203,6 +203,8 @@\n \t\t\tprintf(\"%s: needs update\\n\", ce->name);\n \t\t\tcontinue;\n \t\t}\n+\t\tif (new != ce)\n+\t\t\tfree(ce);\n \t\tactive_cache[i] = new;\n \t}\n }\n\n"},{"id":"424","messageId":"Pine.LNX.4.58.0504162033250.7211@ppc970.osdl.org","threadId":"55","inReplyTo":"7v8y3i5o8t.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] update-cache --refresh cache entry leak","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-17T03:35:07Z","receivedAt":"2005-04-17T03:35:07Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 16 Apr 2005, Junio C Hamano wrote:\n>\n> When update-cache --refresh replaces an existing cache entry\n> with a new one, it forgets to free the original.\n\nI've seen this patch now three times, and it's been wrong every single \ntime. Maybe we should add a comment?\n\nThat active-cache entry you free()'d was not necessarily allocated with \nmalloc(). Most cache-entries are just mmap'ed directly from the index \nfile.\n\nLeaking is ok. We cannot leak too much.\n\n\t\tLinus\n"},{"id":"434","messageId":"7vbr8e2erl.fsf@assigned-by-dhcp.cox.net","threadId":"55","inReplyTo":"Pine.LNX.4.58.0504162033250.7211@ppc970.osdl.org","subject":"Re: [PATCH] update-cache --refresh cache entry leak","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-17T04:44:46Z","receivedAt":"2005-04-17T04:44:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"LT\" == Linus Torvalds <torvalds@osdl.org> writes:\n\nLT> I've seen this patch now three times, and it's been wrong every single \nLT> time. Maybe we should add a comment?\n\nI found out the previous two just after I sent it out.  Sorry\nabout that.\n\n\n"}]}