Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Oct 1998 21:14:10 -0400 (EDT)
From:      Chuck Robey <chuckr@mat.net>
To:        Alex <garbanzo@hooked.net>
Cc:        current <current@FreeBSD.ORG>
Subject:   Re: Something else seems to be leaking...
Message-ID:  <Pine.BSF.4.05.9810062110360.15656-100000@picnic.mat.net>
In-Reply-To: <Pine.BSF.4.00.9810061405260.1673-100000@zippy.dyn.ml.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 6 Oct 1998, Alex wrote:

> Welp.  I finally got aorund to toying with kcminfo (some obscure thing
> from KDE), and it's leaking like a sieve.  Naturally I think that it's to
> blame, however I've managed to narrow it down to a few lines of code
> (which have been reported to not leak on -stable):
> 
>   /*	Q&D hack for swap display. Borrowed from xsysinfo-1.4  */
>   if ((pipe = popen("/usr/sbin/pstat -ks", "r")) == NULL) {
>      used = total = 1;
>      return;
>   }
>   fgets(buf, sizeof(buf), pipe);
>   fgets(buf, sizeof(buf), pipe);
>   fgets(buf, sizeof(buf), pipe);
>   fgets(buf, sizeof(buf), pipe);
>   strtok(buf, " ");
>   total_str = strtok(NULL, " ");
>   used_str = strtok(NULL, " ");
>   pclose(pipe);

This might have nothing to do with your leak, but never do consecutive
calls to strtok, when using NULL as first param, without checking if the
previous return was also NULL.  You might well have run off the end of
the string, and sent strtok off into never never land.

Surprising this hasn't caused SEGVs.

> 
> Commenting everything but the popen and pclose things, doesn't seem to fix
> anything.  This is called from some sort of timer every second or so, so
> the leak is rather apparent.
> 
> - alex
> 
> | "Contrary to popular belief, penguins are not the salvation of modern  |
> | technology.  Neither do they throw parties for the urban proletariat." |
> | Powered by FreeBSD                            http://www.freebsd.org/  |
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-current" in the body of the message
> 
> 

----------------------------+-----------------------------------------------
Chuck Robey                 | Interests include any kind of voice or data 
chuckr@glue.umd.edu         | communications topic, C programming, and Unix.
213 Lakeside Drive Apt T-1  |
Greenbelt, MD 20770         | I run Journey2 and picnic (FreeBSD-current)
(301) 220-2114              | and jaunt (NetBSD).
----------------------------+-----------------------------------------------





To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9810062110360.15656-100000>