# Plug memory leak in update-cache.c

4 messages from 2005-04-14 to 2005-04-16. Participants: Martin Schlemmer, Petr Baudis.
Thread: https://gitlist.dev/t/14

## Martin Schlemmer, 2005-04-14 08:53

Subject: Plug memory leak in update-cache.c
Message-ID: <1113468830.23299.85.camel@nosferatu.lan>
URL: https://gitlist.dev/e/1113468830.23299.85.camel%40nosferatu.lan

```
Hi,

Might not be that an big an issue as it should be freed on exit, but
might cause problems with big trees.

----

Plug memory leak in update-cache.c.

Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>

update-cache.c:  22f3ccd47db4f0888901109a8cbf883d272d1cba
--- 22f3ccd47db4f0888901109a8cbf883d272d1cba/update-cache.c
+++ uncommitted/update-cache.c
@@ -202,6 +202,7 @@
                        printf("%s: needs update\n", ce->name);
                        continue;
                }
+               free(active_cache[i]);
                active_cache[i] = new;
        }
 }


-- 
Martin Schlemmer



update-cache.c:  22f3ccd47db4f0888901109a8cbf883d272d1cba
--- 22f3ccd47db4f0888901109a8cbf883d272d1cba/update-cache.c
+++ uncommitted/update-cache.c
@@ -202,6 +202,7 @@
 			printf("%s: needs update\n", ce->name);
 			continue;
 		}
+		free(active_cache[i]);
 		active_cache[i] = new;
 	}
 }

```

## Petr Baudis, 2005-04-15 23:48

Subject: Re: Plug memory leak in update-cache.c
Message-ID: <20050415234807.GS7417@pasky.ji.cz>
URL: https://gitlist.dev/e/20050415234807.GS7417%40pasky.ji.cz
In-Reply-To: <1113468830.23299.85.camel@nosferatu.lan>

```
Dear diary, on Thu, Apr 14, 2005 at 10:53:50AM CEST, I got a letter
where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> Hi,
> 
> Might not be that an big an issue as it should be freed on exit, but
> might cause problems with big trees.
> 
> ----
> 
> Plug memory leak in update-cache.c.
> 
> Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>
> 
> update-cache.c:  22f3ccd47db4f0888901109a8cbf883d272d1cba
> --- 22f3ccd47db4f0888901109a8cbf883d272d1cba/update-cache.c
> +++ uncommitted/update-cache.c
> @@ -202,6 +202,7 @@
>                         printf("%s: needs update\n", ce->name);
>                         continue;
>                 }
> +               free(active_cache[i]);
>                 active_cache[i] = new;
>         }
>  }

FYI, new could've contained active_cache[i] at that time, so you needed
to check for that. Fixed though, thanks for pointing it out.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

```

## Martin Schlemmer, 2005-04-16 00:00

Subject: Re: Plug memory leak in update-cache.c
Message-ID: <1113609621.8582.12.camel@nosferatu.lan>
URL: https://gitlist.dev/e/1113609621.8582.12.camel%40nosferatu.lan
In-Reply-To: <20050415234807.GS7417@pasky.ji.cz>

```
On Sat, 2005-04-16 at 01:48 +0200, Petr Baudis wrote:
> Dear diary, on Thu, Apr 14, 2005 at 10:53:50AM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > Hi,
> > 
> > Might not be that an big an issue as it should be freed on exit, but
> > might cause problems with big trees.
> > 
> > ----
> > 
> > Plug memory leak in update-cache.c.
> > 
> > Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>
> > 
> > update-cache.c:  22f3ccd47db4f0888901109a8cbf883d272d1cba
> > --- 22f3ccd47db4f0888901109a8cbf883d272d1cba/update-cache.c
> > +++ uncommitted/update-cache.c
> > @@ -202,6 +202,7 @@
> >                         printf("%s: needs update\n", ce->name);
> >                         continue;
> >                 }
> > +               free(active_cache[i]);
> >                 active_cache[i] = new;
> >         }
> >  }
> 
> FYI, new could've contained active_cache[i] at that time, so you needed
> to check for that. Fixed though, thanks for pointing it out.
> 

Urk, no, please drop.  As Ingo pointed out, the memory was obtained via
mmap ...


-- 
Martin Schlemmer


```

## Petr Baudis, 2005-04-16 00:04

Subject: Re: Re: Plug memory leak in update-cache.c
Message-ID: <20050416000436.GT7417@pasky.ji.cz>
URL: https://gitlist.dev/e/20050416000436.GT7417%40pasky.ji.cz
In-Reply-To: <1113609621.8582.12.camel@nosferatu.lan>

```
Dear diary, on Sat, Apr 16, 2005 at 02:00:21AM CEST, I got a letter
where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> On Sat, 2005-04-16 at 01:48 +0200, Petr Baudis wrote:
> > Dear diary, on Thu, Apr 14, 2005 at 10:53:50AM CEST, I got a letter
> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > > Hi,
> > > 
> > > Might not be that an big an issue as it should be freed on exit, but
> > > might cause problems with big trees.
> > > 
> > > ----
> > > 
> > > Plug memory leak in update-cache.c.
> > > 
> > > Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>
> > > 
> > > update-cache.c:  22f3ccd47db4f0888901109a8cbf883d272d1cba
> > > --- 22f3ccd47db4f0888901109a8cbf883d272d1cba/update-cache.c
> > > +++ uncommitted/update-cache.c
> > > @@ -202,6 +202,7 @@
> > >                         printf("%s: needs update\n", ce->name);
> > >                         continue;
> > >                 }
> > > +               free(active_cache[i]);
> > >                 active_cache[i] = new;
> > >         }
> > >  }
> > 
> > FYI, new could've contained active_cache[i] at that time, so you needed
> > to check for that. Fixed though, thanks for pointing it out.
> > 
> 
> Urk, no, please drop.  As Ingo pointed out, the memory was obtained via
> mmap ...

Yes, I've just noticed that. ;-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

```
