summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-02-22 03:10:25 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-02-22 03:10:25 +0000
commit03aaa5c436b88840034be4523838a1097bd69492 (patch)
treef3072ac854b50dc3be79129fdd274a199b955134
parent57de82e571f0e87d43cdc80059281ecc843f95f8 (diff)
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);