summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2012-10-06 20:16:04 +0000
committeravg <avg@FreeBSD.org>2012-10-06 20:16:04 +0000
commit391f37b36d64f7fdfced7f578ce59a046b6c45ad (patch)
tree5772d8e1d3cb180eac3a7df61be8c573ca76b84d /lib
parent737ccc2de8c1853af699fae1ebb1f041b7054bfe (diff)
downloadFreeBSD-src-391f37b36d64f7fdfced7f578ce59a046b6c45ad.zip
FreeBSD-src-391f37b36d64f7fdfced7f578ce59a046b6c45ad.tar.gz
kvm_getprocs: gracefully handle errors from kvm_deadprocs
and don't confuse callers with incorrect return value MFC after: 9 days
Diffstat (limited to 'lib')
-rw-r--r--lib/libkvm/kvm_proc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c
index d1daf77..31258d7 100644
--- a/lib/libkvm/kvm_proc.c
+++ b/lib/libkvm/kvm_proc.c
@@ -593,9 +593,15 @@ liveout:
nprocs = kvm_deadprocs(kd, op, arg, nl[1].n_value,
nl[2].n_value, nprocs);
+ if (nprocs <= 0) {
+ _kvm_freeprocs(kd);
+ nprocs = 0;
+ }
#ifdef notdef
- size = nprocs * sizeof(struct kinfo_proc);
- (void)realloc(kd->procbase, size);
+ else {
+ size = nprocs * sizeof(struct kinfo_proc);
+ kd->procbase = realloc(kd->procbase, size);
+ }
#endif
}
*cnt = nprocs;
OpenPOWER on IntegriCloud