diff options
author | avg <avg@FreeBSD.org> | 2012-10-06 20:17:28 +0000 |
---|---|---|
committer | avg <avg@FreeBSD.org> | 2012-10-06 20:17:28 +0000 |
commit | c04046d195fa77ad0bccdcb041131184b1255eee (patch) | |
tree | 1a9c653ef31beab88a9249d811bbb36582518526 /lib/libprocstat | |
parent | 391f37b36d64f7fdfced7f578ce59a046b6c45ad (diff) | |
download | FreeBSD-src-c04046d195fa77ad0bccdcb041131184b1255eee.zip FreeBSD-src-c04046d195fa77ad0bccdcb041131184b1255eee.tar.gz |
procstat_getprocs: honor kvm_getprocs interface - cnt is signed
MFC after: 10 days
Diffstat (limited to 'lib/libprocstat')
-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 56562e1..11a817e 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) { |