summaryrefslogtreecommitdiffstats
path: root/solaris
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2020-11-22 00:47:00 +0100
committerChristian Göttsche <cgzones@googlemail.com>2020-11-22 10:03:55 +0100
commit51be2d5415cad7981f56a983afa2c0113d86e1be (patch)
tree67dc3dcd437ab76275de0fc5da84317edae71e28 /solaris
parentd2c64c16e6712fe022d9013c5b602754a372338d (diff)
Fix NULL pointer dereference on kstat_lookup failure
Diffstat (limited to 'solaris')
-rw-r--r--solaris/Platform.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/solaris/Platform.c b/solaris/Platform.c
index ff2e5c61..cf85a4c8 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -151,24 +151,22 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
}
int Platform_getMaxPid() {
- kstat_ctl_t* kc = NULL;
- kstat_t* kshandle = NULL;
- kvar_t* ksvar = NULL;
int vproc = 32778; // Reasonable Solaris default
- kc = kstat_open();
- if (kc != NULL) {
- kshandle = kstat_lookup(kc, "unix", 0, "var");
- }
- if (kshandle != NULL) {
- kstat_read(kc, kshandle, NULL);
- }
- ksvar = kshandle->ks_data;
- if (ksvar->v_proc > 0 ) {
- vproc = ksvar->v_proc;
- }
+
+ kstat_ctl_t* kc = kstat_open();
if (kc != NULL) {
+ kstat_t* kshandle = kstat_lookup(kc, "unix", 0, "var");
+ if (kshandle != NULL) {
+ kstat_read(kc, kshandle, NULL);
+
+ kvar_t* ksvar = kshandle->ks_data;
+ if (ksvar && ksvar->v_proc > 0) {
+ vproc = ksvar->v_proc;
+ }
+ }
kstat_close(kc);
}
+
return vproc;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy