Re: patches for a few memory leaks

From: Radu Greab <radu@dont-contact.us>
Date: Mon, 28 May 2001 14:17:04 +0300

On Mon, 28 May 2001 01:51 +0200, Henrik Nordstrom wrote:
> > 4. If squid is compiled with support for delay pools but no pools are
> > configured, then squid will leak a few bytes at every
> > reconfigure/log rotation.
>
> Please explain. This piece of code (parse_delay_pool_count) is only
> called if you configure delay pools, and the allocated data seems to be
> freed properly.

It is not freed properly. If cfg->pools is zero, then xcalloc() is still
called. xcalloc() is coded so that xcalloc(0, ...) is equivalent to
xcalloc(1, ...) and memory is still allocated. But
free_delay_pool_count() does nothing if cfg->pools is zero, so the
memory is not freed.

> > --- squid-2.4.STABLE1/src/cache_cf.c.orig Thu Mar 1 23:49:25 2001
> > +++ squid-2.4.STABLE1/src/cache_cf.c Thu May 24 02:40:42 2001
> > @@ -682,10 +682,12 @@
> > free_delay_pool_count(cfg);
> > }
> > parse_ushort(&cfg->pools);
> > - delayInitDelayData(cfg->pools);
> > - cfg->class = xcalloc(cfg->pools, sizeof(u_char));
> > - cfg->rates = xcalloc(cfg->pools, sizeof(delaySpecSet *));
> > - cfg->access = xcalloc(cfg->pools, sizeof(acl_access *));
> > + if (cfg->pools) {
> > + delayInitDelayData(cfg->pools);
> > + cfg->class = xcalloc(cfg->pools, sizeof(u_char));
> > + cfg->rates = xcalloc(cfg->pools, sizeof(delaySpecSet *));
> > + cfg->access = xcalloc(cfg->pools, sizeof(acl_access *));
> > + }
> > }

Thank you,
Radu Greab
Received on Mon May 28 2001 - 05:32:31 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:02 MST