MOO-cows Mailing List Archive

[Prev][Next][Index][Thread]

Re: possible memory leak in 1.8.0p1



Ahn Jin-su writes:
> In utils.c, binary_to_raw_bytes():
> 
>     const char         *ptr = binary;
> 
>     if (!s)		<- why 'if (!s)'? Isn't s always zero?
>         s = new_stream(100);
>     else
>         reset_stream(s);

The line you left out was the declaration of `s':

	static Stream      *s = 0;

Since `s' is static, it will not be zero on the second entry to this function.

>                     return 0;	<- not freed Stream s...

It's not freed so that it can be reused on later calls without having to
allocate a new one each time.  This idiom is used in many places throughout the
server.  Arguably, this case isn't worth it, but... (*shrug*)

	Pavel



Home | Subject Index | Thread Index