Subject: Re: top chewing memory
To: None <current-users@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: current-users
Date: 06/02/2000 18:02:08
In article <1264.959910603@coconut.itojun.org>,  <itojun@iijlab.net> wrote:
> 
> >Geoff Wing <mason@primenet.com.au> typed:
> >:anyone else getting top leaking memory or just me.
> >:% top -s 0
> >
> >Whoops, just noticed that Mason Loring Bliss has already done a send-pr
> >on this.  That's what I get for noticing a problem before I go to sleep
> >and posting about it just after I wake up :-)
> 
> 	it looks to me like follows:
> 	- cgetstr() calls malloc (as documented in manpage), and returns
> 	  pointer to malloc'ed region via 3rd arg
> 	  bug: leaks memory when realloc fails
> 	- t_getstr does not free the region returned by cgetstr().
> 	  not sure what is the intended behavior (should it return a pointer
> 	  to malloc'ed region, or not).
> 	  bug: it leaks memory when area == NULL.
> 	could someone enlighten me on how t_getstr should behave?

It should not return malloc'ed memory; the whole point is that the
user is providing an area for the string to be copied to.

christos