diff options
| author | Andriy Gapon <avg@FreeBSD.org> | 2012-10-17 11:33:32 +0000 |
|---|---|---|
| committer | Andriy Gapon <avg@FreeBSD.org> | 2012-10-17 11:33:32 +0000 |
| commit | 77c9abffb38f57acf91606ddf8552116328a9d87 (patch) | |
| tree | 081abf01054c4f0d846ff1c8903ebbef8aec5522 | |
| parent | 9e55c0e4a37cb0c3ea0222411696310b253ccf80 (diff) | |
Notes
| -rw-r--r-- | lib/libprocstat/libprocstat.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index 56562e129b157..11a817e090d2c 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -184,15 +184,18 @@ procstat_getprocs(struct procstat *procstat, int what, int arg, struct kinfo_proc *p0, *p; size_t len; int name[4]; + int cnt; int error; assert(procstat); assert(count); p = NULL; if (procstat->type == PROCSTAT_KVM) { - p0 = kvm_getprocs(procstat->kd, what, arg, count); - if (p0 == NULL || count == 0) + *count = 0; + p0 = kvm_getprocs(procstat->kd, what, arg, &cnt); + if (p0 == NULL || cnt <= 0) return (NULL); + *count = cnt; len = *count * sizeof(*p); p = malloc(len); if (p == NULL) { |
