git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Schlemmer <azarah@nosferatu.za.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: git@vger.kernel.org, Linus Torvalds <torvalds@osdl.org>
Subject: Re: [patch] git: fix memory leak #2 in read-cache.c
Date: Thu, 14 Apr 2005 16:25:24 +0200	[thread overview]
Message-ID: <1113488724.23299.106.camel@nosferatu.lan> (raw)
In-Reply-To: <20050414132550.GA25496@elte.hu>

[-- Attachment #1: Type: text/plain, Size: 888 bytes --]

On Thu, 2005-04-14 at 15:25 +0200, Ingo Molnar wrote:
> * 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


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2005-04-14 14:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-14 11:26 [patch] git: fix memory leak in checkout-cache.c Ingo Molnar
2005-04-14 11:35 ` [patch] git: fix memory leak #2 " Ingo Molnar
2005-04-14 11:43   ` [patch] git: cleanup in ls-tree.c Ingo Molnar
2005-04-14 11:54   ` [patch] git: fix memory leaks in read-tree.c Ingo Molnar
2005-04-14 11:58   ` [patch] git: fix rare memory leak in rev-tree.c Ingo Molnar
2005-04-14 12:05     ` [patch] git: report parse_commit() errors " Ingo Molnar
2005-04-14 12:08 ` [patch] git: fix memory leak in show-diff.c Ingo Molnar
2005-04-14 12:18   ` [patch] git: fix overflow in update-cache.c Ingo Molnar
2005-04-14 12:23     ` [patch] cleanup: read_sha1_file() -> malloc_read_sha1_file() Ingo Molnar
2005-04-14 12:53     ` [patch] git: fix 1-byte overflow in show-files.c Ingo Molnar
2005-04-17 23:59       ` Petr Baudis
2005-04-18  8:28         ` Ingo Molnar
2005-04-14 13:03     ` [patch] git: fix memory leaks in update-cache.c Ingo Molnar
2005-04-14 13:08       ` [patch] git: clean up add_file_to_cache() " Ingo Molnar
2005-04-14 13:31       ` [patch] git: fix memory leak #3 " Ingo Molnar
2005-04-14 12:32   ` [patch] git: fix memory leaks in read-cache.c Ingo Molnar
2005-04-14 12:39     ` [patch] git: fix memory leak #2 " Ingo Molnar
2005-04-14 13:25       ` Ingo Molnar
2005-04-14 14:25         ` Martin Schlemmer [this message]
2005-04-14 15:11       ` Linus Torvalds
2005-04-14 15:14         ` Ingo Molnar
2005-04-14 13:12   ` [patch] git: fix memory leak in write-tree.c Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1113488724.23299.106.camel@nosferatu.lan \
    --to=azarah@nosferatu.za.org \
    --cc=git@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).