summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2001-02-22 03:10:24 +0000
committerderaadt <deraadt@openbsd.org>2001-02-22 03:10:24 +0000
commit59611860fb2b751c14843bc47c7a1698b09296cb (patch)
tree67011c9423990bf38351b4ca0bf9498246dcfc7e
parentsync (diff)
downloadwireguard-openbsd-59611860fb2b751c14843bc47c7a1698b09296cb.tar.xz
wireguard-openbsd-59611860fb2b751c14843bc47c7a1698b09296cb.zip
plug mem leak i introduced; spotted by millert
-rw-r--r--usr.bin/top/machine.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c
index 1d49bca8196..a10f505bef8 100644
--- a/usr.bin/top/machine.c
+++ b/usr.bin/top/machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machine.c,v 1.22 2001/02/17 23:01:40 deraadt Exp $ */
+/* $OpenBSD: machine.c,v 1.23 2001/02/22 03:10:24 deraadt Exp $ */
/*
* top - a top users display for Unix
@@ -277,13 +277,15 @@ getprocs(op, arg, cnt)
size_t size = 0;
int mib[4] = {CTL_KERN, KERN_PROC, op, arg};
int st, nprocs;
- struct kinfo_proc *procbase;
+ static struct kinfo_proc *procbase;
st = sysctl(mib, 4, NULL, &size, NULL, 0);
if (st == -1) {
/* _kvm_syserr(kd, kd->program, "kvm_getprocs"); */
return (0);
}
+ if (procbase)
+ free(procbase);
procbase = (struct kinfo_proc *)malloc(size);
if (procbase == NULL)
return (0);